Android SimpleCursorAdapter flow - android

Someone know how SimpleCursorAdapter get database info with no have any content provider interaction? I searched in the docs, but i don't understand yet
I make the Udacity course for learn Android and I use this Fragment, but i can't understand the flow.
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
mForecastAdapter = new SimpleCursorAdapter(
getActivity(),
R.layout.list_item_forecast,
null,
// the column names to use to fill the textviews
new String[]{WeatherContract.WeatherEntry.COLUMN_DATETEXT,
WeatherContract.WeatherEntry.COLUMN_SHORT_DESC,
WeatherContract.WeatherEntry.COLUMN_MAX_TEMP,
WeatherContract.WeatherEntry.COLUMN_MIN_TEMP
},
// the textviews to fill with the data pulled from the columns above
new int[]{R.id.list_item_date_textview,
R.id.list_item_forecast_textview,
R.id.list_item_high_textview,
R.id.list_item_low_textview
},
0
);
mForecastAdapter.setViewBinder(new SimpleCursorAdapter.ViewBinder(){
#Override
public boolean setViewValue(View view, Cursor cursor, int columnIndex) {
boolean isMetric = FormatServices.isMetric(getActivity());
switch (columnIndex) {
case COL_WEATHER_MAX_TEMP:
case COL_WEATHER_MIN_TEMP: {
// we have to do some formatting and possibly a conversion
((TextView) view).setText(FormatServices.formatTemperature(
cursor.getDouble(columnIndex), isMetric));
return true;
}
case COL_WEATHER_DATE: {
String dateString = cursor.getString(columnIndex);
TextView dateView = (TextView) view;
dateView.setText(FormatServices.formatDate(dateString));
return true;
}
}
return false;
}
});
View rootView = inflater.inflate(R.layout.fragment_main, container, false);
final ListView listView = (ListView) rootView.findViewById(R.id.listview_forecast);
listView.setAdapter(mForecastAdapter);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener(){
#Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
/*String forecast = mForecastAdapter.getItem(position);
Toast.makeText(getActivity(), forecast, Toast.LENGTH_SHORT).show();
Intent intent = new Intent(getActivity(), DetailActivity.class)
.putExtra(Intent.EXTRA_TEXT, forecast);
startActivity(intent);*/
}
});
return rootView;
}
Someone can help-me to understand SimpleCursorAdapter flow?

I could understand how it works SimpleCursorAdapter. I using the Loader to get information and added after
#Override
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
mForecastAdapter.swapCursor(data);
}

Related

How to open link Url from listview inside fragment?

If I have a listview inside a fragment, it has a custom layout, an array adapter, a fragment class and an array class.
If I want to open a link when clicking a list contained in the listview, how and where do I put the code?
I have tried the following code that I put in the fragment class, but when I try to click on the available list, my application force closes. Is my code wrong?
list_fish_easy.setOnItemClickListener(new AdapterView.OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Intent linkEasy = new Intent(Intent.ACTION_VIEW, Uri.parse(String.valueOf(arrayListeasy)));
startActivity(linkEasy);
}
});
What I want is that I can open the link contained in the arraylist like the following
public class Fish extends Fragment {
#Nullable
#Override
public View onCreateView(#NonNull LayoutInflater inflater, #Nullable final ViewGroup container, #Nullable Bundle savedInstanceState) {
final View view = inflater.inflate(R.layout.fish_layout, container, false);
ListView list_fish_easy = (ListView) view.findViewById(R.id.list_fish_easy);
final ArrayList<Animal> arrayListeasy= new ArrayList<>();
arrayListeasy.add(new Animal("Contoh Nama 1", "Easy", "Ominvore", "7.5", "30 C", "http://images.google.com/images?um=1&hl=en&safe=active&nfpr=1&q=cabomba_aquatica"));
arrayListeasy.add(new Animal("Contoh Nama 2", "Moderate", "Ominvore", "7.5", "30 C", "http://images.google.com/images?um=1&hl=en&safe=active&nfpr=1&q=cabomba_aquatica"));
arrayListeasy.add(new Animal("Contoh Nama 3", "Difficult", "Ominvore", "7.5", "30 C", "http://images.google.com/images?um=1&hl=en&safe=active&nfpr=1&q=cabomba_aquatica"));
final AnimalAdapter animalAdaptereasy = new AnimalAdapter(getContext(), R.layout.list_fish, arrayListeasy);
list_fish_easy.setAdapter(animalAdaptereasy);
list_fish_easy.setOnItemClickListener(new AdapterView.OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Intent linkEasy = new Intent(Intent.ACTION_VIEW, Uri.parse(String.valueOf(arrayListeasy)));
if(linkEasy.resolveActivity(requireContext().getPackageManager()) != null) {
startActivity(linkEasy);
}
}
});
return view;
}
}
I am very new to creating Android programs. Please help
You are trying to open url from whole arraylist
Intent linkEasy = new Intent(Intent.ACTION_VIEW, Uri.parse(String.valueOf(arrayListeasy)));
Uri.parse(String.valueOf(arrayListeasy)
You should get exact field with url from you arraylist
It will be something like
Uri.parse(String.valueOf(arrayListeasy.get(position).getYourUrlProperty());
whole code
#Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Intent linkEasy = new Intent(Intent.ACTION_VIEW, Uri.parse(String.valueOf(arrayListeasy.get(position).getYourUrlProperty());
if(linkEasy.resolveActivity(requireContext().getPackageManager()) != null) {
startActivity(linkEasy);
}
}
And also you can get rid of String.valueOf( logic
android.content.ActivityNotFoundException: No Activity found to handle Intent
Before staring activities of Implicit intents, you need to check whether the device has some component that can handle this intent or not (this is typically browsers in your case), otherwise you will get this exception.
To do that you can use intent.resolveActivity().
Intent linkEasy = new Intent(Intent.ACTION_VIEW, Uri.parse(String.valueOf(arrayListeasy)));
if(intent.resolveActivity(requireContext().getPackageManager()) != null) {
startActivity(linkEasy);
}

SearchView inside a fragment containing ListView?

I am using fragments in my app. Every fragment has a listview. The ListViews are custom listviews containing a single image view.
<ImageView
android:id="#+id/imageView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
app:srcCompat="#android:drawable/ic_notification_overlay" />
The listview items are images. I want to implement searchview. I want to search by name of each listview item eg "jingle bells etc" and also by number i.e "1,2. . . and so on.
My java file containing listview titles is.
public class carolFrag extends Fragment {
//code
public carolFrag() {
// Required empty public constructor
}
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
}
private static final String TAG = "carolFrag";
#Nullable
#Override
public View onCreateView(LayoutInflater inflater, #Nullable ViewGroup main_content, #Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_carol, main_content, false);
final int[] menuImage = {R.drawable.carol_1_title, R.drawable.carol_2_title,R.drawable.carol_3_title,R.drawable.carol_4_title,R.drawable.carol_5_title,R.drawable.carol_6_title,R.drawable.carol_7_title,R.drawable.carol_8_title,R.drawable.carol_9_title,R.drawable.carol_10_title,R.drawable.carol_11_title};
final ListView listView = (ListView) view.findViewById(R.id.CarolList);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> adapterView, View view, int position, long l) {
Intent intent1 = new Intent (getActivity(), PackageC.class)
intent1.putExtra("position", position);
startActivity(intent1);
}
});
AdapterCarols adapter = new AdapterCarols(getContext(), menuImage);
listView.setAdapter(adapter);
// Inflate the layout for this fragment
return view;
}
}
I am unable to make any logic as the array has drawables in it.
Because the array is full of drawables, and it's not a database thing or anithing every solution you i'll get will be a work around. The simples, i believe, is to have another array maybe an - String[] - with the names of the drawables in the same order they are in the original - final int[] menuImage - you can make the search in the array of String and save the position of the results. Then use those positions to create a new array ( int[] ) putting in this new array the drawables that matches those positions. Finally change the adapter of the list view, passing the array with the results and notifydatachange(); in the listview for it to update visually.
public View onCreateView(LayoutInflater inflater, #Nullable ViewGroup
main_content, #Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_carol, main_content, false);
final int[] menuImage = {R.drawable.carol_1_title, R.drawable.carol_2_title,R.drawable.carol_3_title,R.drawable.carol_4_title,R.drawable.carol_5_title,R.drawable.carol_6_title,R.drawable.carol_7_title,R.drawable.carol_8_title,R.drawable.carol_9_title,R.drawable.carol_10_title,R.drawable.carol_11_title};
final ListView listView = (ListView) view.findViewById(R.id.CarolList);
SearchView sv = view.findviewById(R.id.searchview);
sv.setOnQueryTextListener(new SearchView.OnQueryTextListener()
{
public boolean onQueryTextChange(String par1)
{
return false;
}
public boolean onQueryTextSubmit(String par1)
{
int [] searchresults = PerformSearch(par1);
AdapterCarols newadapter = new
AdapterCarols(getContext(), searchresults);
listView.setAdapter(adapter);
listview.invalidate(); // don't remember listview refresh method. I work with Recyclerview, they have a notifyDatasetChange(); method.
}
});
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> adapterView, View view, int position, long l) {
Intent intent1 = new Intent (getActivity(), PackageC.class)
intent1.putExtra("position", position);
startActivity(intent1);
}
});
AdapterCarols adapter = new AdapterCarols(getContext(), menuImage);
listView.setAdapter(adapter);
// Inflate the layout for this fragment
return view;
}
private int[] PerformSearch(par1)
{
String [] strcarols = {carol_1_title,carol_2_title,carol_3_title,carol_4_title,carol_5_title,carol_6_title,carol_7_title,carol_8_title,carol_9_title,carol_10_title,carol_11_title};
int[] menuImage = {R.drawable.carol_1_title, R.drawable.carol_2_title,R.drawable.carol_3_title,R.drawable.carol_4_title,R.drawable.carol_5_title,R.drawable.carol_6_title,R.drawable.carol_7_title,R.drawable.carol_8_title,R.drawable.carol_9_title,R.drawable.carol_10_title,R.drawable.carol_11_title};
int[] results = new int[];
int carolsresultcount = 0, index =0;
/// simplest way
for(String carol:strcarols)
{
if(carol.contains(par1))
{
results [carolsresultcount++] = menuImage [index];
}
index++;
}
return results;
}
I hope this can solve your problem.

Clicking on each item of listview in a fragment is not working

I have a listview and want to set an onClickListener on each item in this fragment but it's not working.I also wanted to set a contextMenu on the listview and that's not working either.
public View onCreateView(LayoutInflater inflater, #Nullable ViewGroup container, #Nullable Bundle savedInstanceState) {
purchasedItemsView = inflater.inflate(R.layout.purchased_items_fragment , container, false);
db = new StoreDataBase(getActivity() , Consts.StoreDB.DB_NAME , Consts.StoreDB.DB_VERSION);
storeArrayList = new ArrayList<>();
listView = (ListView) purchasedItemsView.findViewById(R.id.storeListView);
adapter = new StoreListViewAdapter(getContext() , R.layout.store_item_row , storeArrayList);
listView.setAdapter(adapter);
adapter .notifyDataSetChanged();
registerForContextMenu(listView);
sendData(purchasedItemsView);
return purchasedItemsView;
}
private void sendData(View view){
Bundle bundle = getArguments();
if (bundle != null) {
final String[] names = bundle.getStringArray(Constc.Data.names);
listView = (ListView) view.findViewById(R.id.storeListView);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Log.e("Data" , "clicked");
}
});
}else{
}
}
Don't reinitialize listview after you have done it once in onCreateView(). Therefore, remove this line from sendData() method:
// remove this
listView = (ListView) view.findViewById(R.id.storeListView);
Then you need to move this part of code outside of if statement or inside of onCreateView() method.
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Log.e("Data" , "clicked");
}
});
Point 1:
Seems your array list is empty, so fill some data
storeArrayList = new ArrayList<>();
//-------------------------------------
Bundle bundle = getArguments();
if (bundle != null) {
final String[] names = bundle.getStringArray(Constc.Data.names);
if(names != null && names.length() > 0) {
storeArrayList.addAll(names);
}
}
//-------------------------------------
listView = (ListView) purchasedItemsView.findViewById(R.id.storeListView);
adapter = new StoreListViewAdapter(getContext() , R.layout.store_item_row , storeArrayList);
listView.setAdapter(adapter);
Point 2: You don't need "notifyDataSetChanged();" right after you set the adapter.
//adapter .notifyDataSetChanged();
Point 3:
Use long click listener for showing context menu
listView.setOnItemLongClickListener(new AdapterView.OnItemClickListener() {
#Override
public void onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
Log.e("Data" , "long press clicked");
//show dialog or context menu dialog.
}
});
Point 4:
comment the sendData method and use the onclick directly
//sendData(purchasedItemsView);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Log.e("Data" , "clicked");
}
});
Hope this helps.
Vote Up - If you like it.

How can I isolate cells within my ListView row for use with setOnItemClickListener instead of the entire row?

I have a list of people that I am pulling from the database with a [modified] SimpleCursorAdapter. I then iterate over the cursor and print information out in a ListView in my app. Right now, it is coded so that when I click on a row, my app performs a function. However, what I would like to do is make it so that when I click on an icon within the row, my app will perform the appropriate function.
Where I am having trouble is isolating a cell within the row for the setOnItemClickListener instead of the entire row.
How do I go about isolating an ImageView within the row instead of the entire row itself?
Here is what I have:
Home.java
package myPackage;
public class Home extends Fragment {
private View rootView;
private AlternateRowColorSimpleCursorAdapter mySimpleCursorAdapter;
private ViewPager myViewPager;
private SwipeRefreshLayout studentSwipeRefresh;
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState){
rootView = inflater.inflate(R.layout.home, container, false);
myViewPager = (ViewPager) getActivity().findViewById(R.id.pager);
studentSwipeRefresh = (SwipeRefreshLayout) rootView.findViewById(R.id.student_swipe_refresh);
return rootView;
}
#Override
public void onViewCreated(View rootView, Bundle savedInstanceState) {
super.onViewCreated(rootView, savedInstanceState);
drawTheStudentView();
studentSwipeRefresh.setColorSchemeColors(Color.parseColor(Constants.RED), Color.parseColor(Constants.ORANGE), Color.parseColor(Constants.YELLOW), Color.parseColor(Constants.GREEN), Color.parseColor(Constants.BLUE), Color.parseColor(Constants.INDIGO), Color.parseColor(Constants.VIOLET));
studentSwipeRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
#Override
public void onRefresh() {
studentSwipeRefresh.setRefreshing(false);
drawTheStudentView();
}
});
}
private void drawTheStudentView(){
DatabaseHelper myDBHelper = new DatabaseHelper(getActivity());
Cursor studentCursor = myDBHelper.getStudentsCursor();
String[] fromColumns = {"_id","studentID","status","location"};
int[] toViews = {R.id.student_number_textview, R.id.student_id_textview};
mySimpleCursorAdapter = new AlternateRowColorSimpleCursorAdapter(getActivity(), R.layout.student_layout, studentCursor, fromColumns, toViews, 0);
// Replace the _id column with a student count
mySimpleCursorAdapter.setViewBinder(new SimpleCursorAdapter.ViewBinder() {
#Override
public boolean setViewValue(View view, Cursor cursor, int columnIndex) {
String counter = Integer.toString((cursor.getPosition()+1));
TextView modifiedTextView = (TextView) view;
if(columnIndex == 0){
modifiedTextView.setText(counter);
return true;
}
return false;
}
});
ListView myListView = (ListView) rootView.findViewById(R.id.student_row);
// Listen for somebody clicking on a Student ID, and process
myListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Cursor subCursor = (Cursor) mySimpleCursorAdapter.getItem(position);
String zapNumber = subCursor.getString(subCursor.getColumnIndex("studentID"));
StudentStatus studentStatus = (StudentStatus) getFragmentManager().findFragmentByTag(getFragmentTag(Constants.TAB_INDEX_PATIENT_VITALS));
studentStatus.setZapNumber(zapNumber);
myViewPager.setCurrentItem(Constants.TAB_INDEX_PATIENT_VITALS);
}
});
// Draw the list
myListView.setAdapter(mySimpleCursorAdapter);
myDBHelper.close();
}
// Pass me a tab index (see Constants.java) and I'll return a refrence to that tab.
private String getFragmentTag(int tagID){
return "android:switcher:" + R.id.pager + ":" + tagID;
}
}
AlternateRowColorSimpleCursorAdapter.java
package myPackage;
public class AlternateRowColorSimpleCursorAdapter extends SimpleCursorAdapter {
public AlternateRowColorSimpleCursorAdapter(Context context, int layout, Cursor c, String[] from, int[] to, int flags) {
super(context, layout, c, from, to, flags);
}
#Override
public View getView(int position, View convertView, ViewGroup parent){
View row = super.getView(position, convertView, parent);
if(position % 2 == 0){
row.setBackgroundColor(Color.parseColor(Constants.WHITE));
} else {
row.setBackgroundColor(Color.parseColor(Constants.LIGHTGREY));
}
return row;
}
}
student_layout.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content"
android:layout_width="match_parent">
<TextView
android:id="#+id/student_number_textview"
android:typeface="monospace"
android:layout_weight="1"
android:textStyle="bold"
style="#style/StudentStyle" />
<TextView
android:id="#+id/student_id_textview"
android:typeface="monospace"
style="#style/StudentStyle" />
<ImageView
android:id="#+id/student_status_button"
style="#style/studentIconLink"
android:src="#drawable/status_icon"/>
<ImageView
android:id="#+id/student_location_button"
style="#style/studentIconLink"
android:src="#drawable/location_icon"/>
</LinearLayout>
A possibility to define a callback interface for communication between the views created in your Adapter and your Fragment.
Have your Fragment implement this interface and pass in a reference to your Fragment in your Adapter's constructor. In your getView() method in the adapter, you can set an OnClickListener on your ImageView that you want to listen for, and then trigger the callback you passed into your Adapter. Note: you can pass back something like position in this callback so you know which row's ImageView was selected.

Wrong ListView item is passed by the intent

I am using BackendLess backend service, but my prob is (i guess) more to android/java. So even if u are not familiar with BackendLess, i guess u can help, if u know of course :)
I have there a Fragment that calls and opens a DialogFragment with a ListView.
Using there an iterator to retrieve the data. It brings each column from the data table as an Array.
I set an onClickedItemListener that when item is clicked, it send the value to a TextView in the Fragment it was called from.
The data comes in the wrong order - didnt get how to do a sortBy, that connects to the bigger prob i have there -
There is a column there named "PropertyTypes". It holds 4 strings, which are coming out in the opposite order that i need. I want the "A" first, and get:
"D"
"C"
"B"
"A"
ok, so far no big deal, i guess can be sorted out with a sortBy that i just dont know how to do.
But... what happens is that it sends the wrong value to the TextView, meaning, for example, when i press "C" it set "A" on the TextView and so on, and, when i press the last one, in this case "A", the app is crashing...
What the hell is going on there?? :))
Here is the code -
The DialogFragment code:
public class OptionDialogFragment extends DialogFragment implements
AdapterView.OnItemClickListener {
ListView mylist;
TextView chosenProperty;
TextView presentListItem;
ArrayAdapter adapter;
#Override
public View onCreateView(final LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
//mylist.addHeaderView(inflater.inflate(R.layout.option_dialog_header, null, false));
View view = inflater.inflate(R.layout.option_dialog_content, null, false);
mylist = (ListView) view.findViewById(R.id.list);
View headerView = inflater.inflate(R.layout.option_dialog_header, mylist, false);
headerView.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
dismiss();
}
});
mylist.addHeaderView(headerView);
View footerView = inflater.inflate(R.layout.option_dialog_footer, mylist, false);
footerView.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
dismiss();
}
});
mylist.addFooterView(footerView);
chosenProperty = (TextView) view.findViewById(R.id.chosenProperty);
getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);
return view;
}
#Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
final ArrayList<String> propertyTypes = new ArrayList<String>();
final ArrayList<Integer> numOfRoomies = new ArrayList<Integer>();
Backendless.Data.of(DialogOptions.class).find(new AsyncCallback<BackendlessCollection<DialogOptions>>() {
#Override
public void handleResponse(final BackendlessCollection<DialogOptions> dialogOptions) {
final Iterator<DialogOptions> iterator = dialogOptions.getCurrentPage().iterator();
while (iterator.hasNext()) {
DialogOptions dialogOptionsObject = iterator.next();
propertyTypes.add(dialogOptionsObject.getPropertyTypes());
// numOfRoomies.add( dialogOptionsObject.getNumOfRoomies() );
}
adapter = new ArrayAdapter<String>(getActivity(), R.layout.dialog_option_list_item, R.id.presentListItem, propertyTypes);
mylist.setAdapter(adapter);
mylist.setOnItemClickListener(new AdapterView.OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
String chosenItem = propertyTypes.get(position);
Intent intent = new Intent();
intent.putExtra("chosenItem", chosenItem);
getTargetFragment().onActivityResult(
getTargetRequestCode(), Activity.RESULT_OK, intent);
dismiss();
}
});
}
#Override
public void handleFault(BackendlessFault fault) {
// TODO: make sure to log the exception, just in case
}
});
}
}
This is the Relevant code in the Fragment that calls the DialogFragment:
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.find_a_place, container, false);
chosenProperty = (TextView) view.findViewById(R.id.chosenProperty);
return view;
}
#Override
public void onViewCreated(final View view, Bundle savedInstanceState) {
final LinearLayout propertTypes = (LinearLayout)view.findViewById(R.id.propertyTypes);
propertTypes.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
showDialog(getActivity(), "OptionDialog");
}
});
}
private void showDialog(FragmentActivity activity, String optionDialog) {
android.support.v4.app.FragmentManager manager = getFragmentManager();
DialogFragment dialog = new OptionDialogFragment();
dialog.setTargetFragment(this, 0);
dialog.show(manager, "OptionDialog");
dialog.setCancelable(true);
}
#Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
switch(requestCode) {
case 0:
if (resultCode == Activity.RESULT_OK) {
if(data!=null){
// set value to your TextView
chosenProperty.setText(data.getStringExtra("chosenItem"));
}
}
break;
}
}
Thanks a lot in advance for any answer!!
Reference :-
https://backendless.com/feature-47-loading-data-objects-from-server-with-sorting/
To Sort while retrieving Object use :-
QueryOptions queryOptions = new QueryOptions();
queryOptions.addSortByOption( "created ASC" );
dataQuery.setQueryOptions( queryOptions );
Use Query as below:-
// fetch restaurants
Backendless.Data.of( Restaurant.class ).find( dataQuery, new AsyncCallback<BackendlessCollection<Restaurant>>(){

Categories

Resources