I am trying to implement onItemClickListener in Fragment class but unfortunately it is not working properly... here is the source code.. please let me know what is the error??
NetworkDetailsFragment.java(My Fragment class)
public class NetworkDetailsFragment extends Fragment implements AdapterView.OnItemClickListener{
private ListView listView;
private View networkDetailsView;
private QOSNetworkDetailsAdapter qosNetworkDetailsAdapter;
private QOSNetworkDetailsDatabaseHelper qosNetworkDetailsDatabaseHelper;
private SimpleCursorAdapter simpleCursorAdapter;
private String LOG_TAG = NetworkDetailsFragment.class.getSimpleName();
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
Log.i(LOG_TAG, "Inside onCreateView() method");
networkDetailsView = inflater.inflate(R.layout.network_details, container, false);
listView = (ListView) networkDetailsView.findViewById(R.id.list_view);
qosNetworkDetailsDatabaseHelper = new QOSNetworkDetailsDatabaseHelper(getActivity());
Cursor cursor = qosNetworkDetailsDatabaseHelper.getRecord();
String[] columns = {QOSNetworkDetailsDatabaseConstants.COLUMN_NETWORK_TYPE,
QOSNetworkDetailsDatabaseConstants.COLUMN_NETWORK_STATUS,
QOSNetworkDetailsDatabaseConstants.COLUMN_LATITUDE,
QOSNetworkDetailsDatabaseConstants.COLUMN_LONGITUDE,
QOSNetworkDetailsDatabaseConstants.COLUMN_TIME};
int[] to = new int[]{
R.id.networkType,
R.id.networkStatus,
R.id.latitudeAndLongitude,
R.id.date
};
/*SimpleCursorAdapter simpleCursorAdapter = new SimpleCursorAdapter(
this, R.layout.activity_network_info,
cursor,
columns,
to,
0);*/
simpleCursorAdapter = new SimpleCursorAdapter(getActivity(), R.layout.activity_network_info, cursor, columns, to, 0);
qosNetworkDetailsAdapter = new QOSNetworkDetailsAdapter(getActivity().getApplicationContext(), qosNetworkDetailsDatabaseHelper.getRecord(), false);
listView.setAdapter(qosNetworkDetailsAdapter);
return networkDetailsView;
}
#Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
listView.setOnItemClickListener(this);
}
#Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
Cursor cursor = (Cursor) parent.getItemAtPosition(position);
String countryCode =
cursor.getString(cursor.getColumnIndexOrThrow("code"));
Toast.makeText(getActivity().getApplicationContext(),
countryCode, Toast.LENGTH_SHORT).show();
}
}
network_details.xml(i.e list_view.xml)
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:contentDescription="#string/network_details_fragment_string"
android:descendantFocusability="blocksDescendants" >
<ListView
android:id="#+id/list_view"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
</LinearLayout>
activity_network_info.xml(list items)
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/scroller"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true"
android:descendantFocusability="blocksDescendants">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="#drawable/black"
>
<TextView
android:id="#+id/networkStatus"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#drawable/white"
android:textSize="15sp" />
<TextView
android:id="#+id/networkType"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#drawable/white"
android:textSize="15sp" />
<TextView
android:id="#+id/latitudeAndLongitude"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#drawable/lightblue"
android:textSize="15sp" />
<TextView
android:id="#+id/date"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#drawable/lightblue"
android:textSize="15sp" />
</LinearLayout>
</ScrollView>
List is getting populated to the screen... but onItemClickListener is not working in this code... please let me know what is the error.. Thanks
Try to extend FragmentActivity instead of Fragment...
If you use a ListFragment, your ListView Id in layout must be android.R.id.list
like that:
<?xml version="1.0" encoding="utf-8"?>
<ListView xmlns:android="http://schemas.android.com/apk/res/android" android:id="#android:id/list" />
Related
How can I populate a listview using a Dictionary from a fragment for each row and use a custom layout ? In layout of row, contains two textview and one Imageview.
My Layout with listview:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:id="#android:id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical"
android:background="#ff04aefa" />
</LinearLayout>
Layout Row:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:src="#android:drawable/ic_menu_gallery"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/imageView1" />
<LinearLayout
android:id="#+id/singleMessageContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="5dip"
android:paddingLeft="10dip"
android:text="Texview 1"
android:textColor="#android:color/background_light" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="5dip"
android:paddingLeft="10dip"
android:textColor="#android:color/background_light" />
</LinearLayout>
</LinearLayout>
My ListFragment.cs:
Dictionary <string,string> _Dic = new Dictionary<string,string>();
string[] _ValuesOfDic = { };
public override View OnCreateView (LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
_Dic = MyProject.UtilDic.ReturnDic ();
_ValuesOfDic = new string[_Dic.Count];
int cont = 0;
foreach (var item in _Dic) {
_ValuesOfDic[cont] = item.Value;
cont++;
}
View view = inflater.Inflate(Resource.Layout.LayoutListOfValues, null); //Layout with listView
ListView listview = (ListView)view.FindViewById (Android.Resource.Id.List);
listview.Adapter = new ArrayAdapter <string> (this.Activity,
Android.Resource.Layout.SimpleListItem1,
_ValuesOfDic); //Here I want to use the layout for the rows of listview
return view;
}
public override void OnListItemClick (ListView l, View v, int position, long id)
{
string value = l.Adapter.GetItem (position).ToString ();
string key = _Dic.FirstOrDefault (x => x.Value.Contains (value)).Key;
Console.WriteLine ("Value: " + value);
Console.WriteLine ("Key: " + key);
}
Create a Custom Adapter, which inherits from BaseAdapter and can take your Dictionary and present accordingly. ArrayAdapter only takes lists or arrays.
So something like:
public class MyDictionaryAdapter : BaseAdapter
{
private Dictionary<TX,TY> _dict;
public MyDictionaryAdapter(Dictionary<TX, TY> dict)
{
_dict = dict;
}
public override View GetView (int position, View convertView, ViewGroup parent)
{
// populate your listview items here
}
}
You can read more about ListView and Adapters here: http://developer.xamarin.com/guides/android/user_interface/working_with_listviews_and_adapters/
I've been struggling like crazy to add a button below a ListView of a ListFragment, I've followed most suggestions of the questions How to show a button at the end of an Android ListView, Android Layout with ListView and Buttons and Displaying the button at the end of the ListView with Linear Layout. I just havent tried yet the ListView#addFooterView() yet as I would prefer not to add the button programmatically.
I have the impression that the reason why theirs solutions work for them and not for me is due to the fact that my layout refers to a fragment layout under an activity that has a tab action bar.
As you can see in the picture, the shadow of the linear layout in which my button is part of can be seen overridden by the navigation bar. And the amount overridden resembles the height of the tabs
My fragment layout is the one below:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/service_notif_list_fragment"
>
<TextView
android:id="#+id/serviceName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge" />
<ListView android:id="#id/android:list"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="2.0"
android:drawSelectorOnTop="false"/>
<TextView android:id="#id/android:empty"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="No data"/>
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
style="#android:style/ButtonBar">
<Button
android:id="#+id/delServiceButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end|left"
android:text="Delete Service" />
</LinearLayout>
</LinearLayout>
And my fragment code does not do anything exceptional, except using Loaders to load the list data from the db
public class ServiceSpecifNotListFragment extends ListFragment implements
LoaderCallbacks<Cursor> {
Button deleteServiceButton = null;
String serviceUri;
String servName;
TextView serviceName = null;
private NotificationCursorAdapter adapter;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
String[] uiBindFrom = { ...};
int[] uiBindTo = { ... };
getLoaderManager().initLoader(Constants.SERVICE_SPECIFIC_LIST_LOADER, null, this);
adapter = new NotificationCursorAdapter(
getActivity().getApplicationContext(), R.layout.service_specifc_notif_row,
null, uiBindFrom, uiBindTo,
CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER);
setListAdapter(adapter);
}
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.service_notif_list_fragment, container, false);
serviceName = (TextView) rootView.findViewById(R.id.serviceName);
serviceName.setText(servName); // the name is set in the onCreateLoader
deleteServiceButton = (Button) rootView.findViewById(R.id.delServiceButton);
deleteServiceButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO
}
});
return rootView;
}
#Override
public Loader<Cursor> onCreateLoader(int arg0, Bundle bundleArg) {
String[] projection = { ...};
Bundle arg = this.getArguments();
CursorLoader cursorLoader = new CursorLoader(getActivity(),
NotificationContentProvider.CONTENT_URI, projection, selection, selectionArgs, NotificationData.SERVER_TIME + " DESC");
return cursorLoader;
}
else{
Log.d(TAG, "failed to retrieve service name");
return null;
//TODO: find a destroy self
}
}
#Override
public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) {
adapter.swapCursor(cursor);
}
#Override
public void onLoaderReset(Loader<Cursor> arg0) {
adapter.swapCursor(null);
}
#Override
public void onDestroyView(){
super.onDestroyView();
Log.d(TAG, "on destroy view");
}
#Override
public void onDestroy(){
super.onDestroy();
Log.d(TAG, "on destroy");
}
}
If needed, I can post the code of the main activity, and on...
Try a RelativeLayout, where you can set the ListView to fill the space between the TextView and LinearLayout containing the button(s):
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/service_notif_list_fragment" >
<TextView
android:id="#+id/serviceName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_alignParentTop="true" />
<LinearLayout
android:id="#+id/layoutButton"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
style="#android:style/ButtonBar">
<Button
android:id="#+id/delServiceButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end|left"
android:text="Delete Service" />
</LinearLayout>
<ListView android:id="#id/android:list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_above="#id/layoutButton"
android:layout_below="#id/serviceName"
android:drawSelectorOnTop="false"/>
</RelativeLayout>
Finally what worked here was to set different layout weights for the different elements in the linear layout, but having a weightSum on the top layout as shown below.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/service_notif_list_fragment"
android:weightSum="1.0">
<TextView
android:id="#+id/serviceName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge" />
<ListView android:id="#id/android:list"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="0.8"
android:drawSelectorOnTop="false"/>
<TextView android:id="#id/android:empty"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="No data"/>
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#android:color/transparent"
style="#android:style/ButtonBar">
<Button
android:id="#+id/delServiceButton"
android:layout_weight="0.05"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end|left"
android:text="Delete Service" />
</LinearLayout>
</LinearLayout>
The SimpleCursorAdapter is not populating my ListView, no error, just nothing happens.
Could someone help me find the error?
1) Layout with ListView component (tab_frag1_layout.xml):
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#FF0000"
android:orientation="vertical" >
<ListView
android:id="#+id/lvVehicle"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</LinearLayout>
2) Layout to represent row (vehicle_row.xml):
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="10dip" >
<TableRow
android:id="#+id/tableRow1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="1dip" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_arrow_right"
android:contentDescription="#null"
android:adjustViewBounds="true"
android:layout_marginRight="3dip"
android:layout_gravity="center_vertical" />
<TextView
android:id="#+id/plate"
style="#style/vehicleDefaultFont.plate"
android:text="#string/label_text_view" />
<TextView
android:id="#+id/hyphen"
android:text="#string/label_hyphen" />
<TextView
android:id="#+id/model"
android:text="#string/label_text_view" />
</TableRow>
<TableRow
android:id="#+id/tableRow2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="1dip" >
<TextView
android:id="#+id/driver"
style="#style/vehicleDefaultFont.driver"
android:layout_span="4"
android:text="#string/label_text_view" />
</TableRow>
</TableLayout>
3) Fragment Class:
public class Tab1Fragment extends Fragment {
String TAG = getClass().getName();
private VehicleDbAdapter dbHelper;
private SimpleCursorAdapter dataAdapter;
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.tab_frag1_layout, container, false);
dbHelper = new VehicleDbAdapter(getActivity());
dbHelper.open();
dbHelper.deleteAllVehicles();
dbHelper.insertVehicles();
Cursor cursor = dbHelper.fetchAllVehicles();
if(cursor != null && cursor.getCount() > 0) {
String[] columns = new String[] {
VehicleDbAdapter.KEY_MODEL,
VehicleDbAdapter.KEY_PLATE,
VehicleDbAdapter.KEY_DRIVER
};
int[] to = new int[] {
R.id.model,
R.id.plate,
R.id.driver,
};
dataAdapter = new SimpleCursorAdapter(
view.getContext(),
R.layout.vehicle_row,
cursor,
columns,
to,
0);
ListView listView = (ListView) view.findViewById(R.id.lvVehicle);
listView.setAdapter(dataAdapter);
Log.i(TAG, "Cursor = " + cursor.getCount());
} else {
Log.i(TAG, "Cursor = " + cursor.getCount());
}
return view;
}
}
Curiously:
My cursor contains an _id field.
I doublechecked my cursor and it has 7 rows.
07-21 01:30:22.215: I/ Cursor = 7
I tried using the layout to the generic android list layout, but nothing doing :(
dataAdapter = new SimpleCursorAdapter(
view.getContext(),
android.R.layout.simple_list_item_1,
cursor,
columns,
to,
0);
Any help is welcome.
The TextViews that you have defined in vehical_row.xml: #+id/plate, #+id/hyphen, #+id/model and #+id/driver are all missing the layout_width and the layout_height attributes. These are required.
For now, set these attributes as "wrap_content". For example:
<TextView
android:id="#+id/plate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="#style/vehicleDefaultFont.plate"
android:text="#string/label_text_view" />
Do the above for the other three as well. This should work for you.
I think you have problem at XMl. Check id of your listview.
android:id="#+android:id/mainListView">
I've got a TextView and it's getting a list in it.
public class Home extends ListActivity {
ListView listView;
static final String[] Liste = {"a", "b", "c"};
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setTitle("CalcPlus");
listView = getListView();
//Own row layout
listView.setAdapter(new ArrayAdapter<String>(this,
R.layout.activity_home, R.id.text, Liste));
//listView.setOnItemClickListener(this);
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_home, menu);
return true;
}
Now I want a small grey description of the list item, like here:
I read these tutorials: 1 and 2 but I have to admit, I don't understand what they say.
Can someone explain how to use them? Do I have to remove my TextView/List I have now? Is there another way to make a little description, without using a custom ListView?
Here's my xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ListView android:id="#android:id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:divider="#b5b5b5"
android:dividerHeight="1dp"
android:listSelector="#drawable/list_selector" />
<TextView
android:id="#+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text=""
android:textAllCaps="false"
android:textSize="22dp"
android:textStyle="bold"
android:layout_marginBottom="50dp"
android:layout_marginTop="50dp"
android:layout_marginLeft="2dp"/>
I don't really use the listview "list", just for testing purposes.
You need to understand that the following line
listView.setAdapter(new ArrayAdapter<String>(this,
R.layout.activity_home, R.id.text, Liste));
means that you want to use layout.activity_home.xml for each item's view of your list.
So I don't see why there is a ListView inside it...
By default the ArrayAdapter uses one single text field per item. If you want a more complex item layout, you need to override the getView() method of your adapter.
Here is the simplest solution I can think of:
In Home.java:
public class Home extends ListActivity {
ListView listView;
static final String[] Liste = {"a", "b", "c"};
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setTitle("CalcPlus");
listView = getListView();
listView.setAdapter(new ArrayAdapter<String>(this, R.layout.list_item, R.id.text, Liste) {
#Override
public View getView(int position, View convertView, ViewGroup parent) {
View view = super.getView(position, convertView, parent);
String item = getItem(position);
TextView subTitleView = (TextView) view.findViewById(R.id.subtitle);
subTitleView.setText("Subtitle of " + item);
return view;
}
});
}
}
And layout/list_item.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="10dp" >
<TextView
android:id="#+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text=""
android:textAllCaps="false"
android:textSize="22dp"
android:textStyle="bold" />
<TextView
android:id="#+id/subtitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text=""
android:textAllCaps="false"
android:textSize="16dp"
android:textStyle="normal" />
</LinearLayout>
First use the setContentView and call the layout.. From the layout call the LISTVIEW. then using the adapter put the LISTE inside the list view use your data.
I'm trying to make the android-actionbar plugin working in my ListActivity,
Here's my Class :
public class DisciplinesController extends ListActivity {
private DisciplinesModel dbHelper;
private Cursor cursor;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.list_action);
ActionBar actionBar = (ActionBar) findViewById(R.id.actionbar);
dbHelper = new DisciplinesModel(this);
dbHelper.open();
if (dbHelper.fetchDisciplineCount() == 0) {
dbHelper.fetch();
}
cursor = dbHelper.fetchAllDisciplines();
startManagingCursor(cursor);
ListAdapter adapter = new SimpleCursorAdapter(this, R.id.list,
cursor, new String[] { "name" }, new int[] { R.id.discipline_name});
setListAdapter(adapter);
getListView().setTextFilterEnabled(true);
}
}
and my XML layout :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<com.markupartist.android.widget.ActionBar
android:id="#+id/actionbar" style="#style/ActionBar" />
<LinearLayout android:id="#+id/list" android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView android:id="#+id/discipline_name"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:gravity="center_vertical" android:paddingLeft="6dip"
android:minHeight="?android:attr/listPreferredItemHeight" />
</LinearLayout>
</LinearLayout>
I always have this exception :
Your content must have a ListView whose id attribute is 'android.R.id.list'
Do you have an idea ??
Thanks !
In your XML layout you must include a ListView element with the #android:id/list id.
<ListView
android:id="#android:id/list"
...
/>
Basically, you need to rip out the section LinearLayout into a new file (e.g. list_item.xml). Replace this with a listview in your list_action.xml
<ListView
android:id="#android:id/list"
android:layout_width="fill_parent"
andrdoi:layout_height="wrap_content" />
Then change R.id.list in your SimpleCursorAdapter constructor to R.layout.list_item.