i have an existing project, it's a quiz app and i want to put a button that sends the user to a web site if he gets the wrong answer and wants to get infomations on the correct answer and i want to know how to do it
first check the answer is correct or not. if is it right use condition like
if(answer){ // answer is true
// todo
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.google.com"));
startActivity(browserIntent);
}else{
// todo
}
Related
I am designing a guide application. When I click on the person I selected from the list, it should go to the profile page I prepared. I will be very happy if you can help :)
https://i.stack.imgur.com/AANpq.png
You're using ListView, which is a type of AdapterView.
You can respond to click events (in this case same thing as tap events) by registering an onItemClickListener as described here in the Android documentation:
listView.onItemClickListener = AdapterView.OnItemClickListener { parent, view, position, id ->
val user: UserDto = adapter.getItem(position)
//start new Activity through Intent here
}
You combine the information about the currently presented UserDtos from your adapter with the OnItemClickListener position parameter to get the UserDto whose view the user clicked on.
You'll then want to start a new Intent, passing the user information to the new activity with the extra information that Intents can hold. The Android developer documentation has an example for something similar too.
Im using the iOS SDK and I would like to turn off reactions for my users in chat.
In my subclass of ChatViewController I have overridden defaultMessageActions:
override var defaultMessageActions: ChatViewController.MessageAction {
return [.delete, .copy, .flagMessage, .flagUser]
}
However, when a user taps on a message cell, the reaction window still pops up. I found where there is happening in ChatViewController+Cells.swift:
if let presenter = presenter, presenter.channel.config.reactionsEnabled {
showReactions(from: cell, in: message, locationInView: tapGesture.location(in: cell))
}
reactionsEnabled is true here and so the reactions view is popping up. I tried to find a away to set Channel.Config.reactionsEnabled to false, but had no success.
How do I set reactionsEnabled to false? Any help would be appreciated.
The correct way to disable reactions is to go to your Stream Chat dashboard, select the channel types you don't want reactions enabled for, disable it and save. After that, the reactions UI will not be displayed.
Disabling just from client-side like you were trying to do is not supported with the provided UI components.
I am having issues with my app returning to the foreground every time the user presses the back button. I believe this may be because there is a sound playing module that restarts the activity although this is just my hypothesis. However whenever I press the home (middle) button the app is sent to the background and everything works accordingly. I would like to emulate this functionality by capturing the back press event and handle it in a similar manner to the home button. While navigating the source, i've found the following handler in
android/reactnativenavigation/layouts/SingleScreenLayout.java
#Override
public boolean onBackPressed() {
if (handleBackInJs()) {
return true;
}
if (stack.canPop()) {
stack.pop(true, System.currentTimeMillis());
EventBus.instance.post(new ScreenChangedEvent(stack.peek().getScreenParams()));
return true;
} else {
return false;
}
}
I can understand at a glance what is being done however I am not very familiar with Java and don't want to introduce any bugs involving the native side of the app, could anyone kindly point out what I would need to modify?
So, you need to capture "the hardware back button" press not the home button right?
check here for the react-native way of doing it
I have searched this forum for my problem but didn't find anything that suited, Im having a problem with my program flow.
I have a MobileService on Azure that has a question table, my app has a main menu and quiz button that takes the user to the quiz page, on the quiz page I have a start quiz button that shows the first question in the list.
This is the code im using to get the questions from the database, I placed it in the pages constructor and now when the user presses the quiz button there is a delay in the page opening which isn't that bad as its not a long wait, only a few seconds, is there a better way to do this?
Task<IMobileServiceTable<Question>> getDataFromDatabase = new Task<IMobileServiceTable<Question>>(getQuestions);
getDataFromDatabase.Start();
QuestionList = await getDataFromDatabase;
In the same function I have this code which modifies the start quiz button isEnabled attribute. This stops the quiz going forward unless the data has came through from the server, but its not working all the time and sometimes the start button isenabled is set to true and I get nullreference from my MobileServiceCollectionView QuestionList even though the task has completed.
Task<bool> assignData = new Task<bool>(assignTabletoitems);
assignData.Start();
startbutton.IsEnabled = await assignData;
Any help on this would be appreciated.
Thanks
You shouldn't have to create a new instance of Task<T> to query the database (you haven't provided the definition of getQuestions which is used in your first code snippet, so I can't tell whether that code is doing what it's supposed to). What you'd typically do is to get a table for the appropriate type from the MobileServiceClient object, and then query on it:
var client = new MobileServiceClient(appUrl, appKey);
var table = client.GetTable<Question>();
var questionList = await table.ToListAsync();
Regarding your second code snippet, without the definition of assignTabletoitems it's really hard to know what you're intending that code to do.
I have a site in SharePoint and I want to custom delete from a list. So, I'm creating the
public class ListItemEventReceiver : SPItemEventReceiver
{
public override void ItemDeleting(SPItemEventProperties properties)
{
if (properties.ListTitle.Equals("Projects List"))
{
Projects pr = new Projects();
string projectName = properties.ListItem["Project Name"].ToString();
pr.DeleteProject(projectName);
}
}
}
Where 'Projects' class has 'DeleteProject' method who deletes the item.
But it's doing nothing :(
I mention that everything it's ok in Feature.xml
Where am I wrong?
Edit (from 'answer'):
Yes, I've tried this:
properties.ErrorMessage = "projectName :" + projectName;
properties.Cancel = true;
in if clause and the event it's firing and displays the project name corectly.
I'm the farm administrator, and site administrator with full control over this site.
DeleteProject method it's right, because I've tried it in some other application (c#) and it's works fine.
A couple of things to check:
Is your list item reciever connected to the list, so that it fires?
Does the user that causes the trigger to fire have the the right to delete items?
Is there any programming error in DeleteProject?
Try putting in some logging to see how far it is running.
Edit
Could the problem be here:
string projectName = properties.ListItem["Project Name"].ToString();
Is the list item called "Project Name" with a space in the name?
Edit 2
From your comments, the combination of authentication and connection string means that it is the security context of the logged on user that is being used against the database. Check the rights of your user.
If event is firing and the only method pr.DeleteProject(projectName); is not working properly then it is difficult to guess what is wrong. If it is not confidential, please post your code and then I shall be in better position to identify what is wrong.
By the way, are you calling .Update() Method on list?
Please check out this link http://msdn.microsoft.com/en-us/library/ms431920.aspx
One more thing to care about is Itemed and Iteming events. It is better to use Before or After properties as appropriate in case of Item*ing events.
Regards,
Azher Iqbal