Hi, when I go to activity say unfortantly.... and close program
in my erro list say : Your content must have a ListView whose id attribute is 'android.R.id.list'
its my xml of activity :
="1.0"="utf-8"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ListView
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</ListView>
</LinearLayout>
and its my list_item activity :
="1.0"="utf-8"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<ImageView
android:id="@+id/img1"
android:layout_width="60dp"
android:layout_height="60dp"
android:padding="5dp"
android:layout_gravity="left" />
<TextView
android:id="@+id/txt1"
android:layout_width="80dp"
android:layout_height="wrap_content"
android:padding="5dp"
android:textSize="15sp"
android:text="Text_1" />
</LinearLayout>
</LinearLayout>
and its my java cod :
package com.momeni.shams;
import android.app.ListActivity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.ListView;
public class Showperson extends ListActivity {
public ListView list1;
public String number_of_keys;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_showperson);
Bundle bundle = getIntent().getExtras();
String catid = bundle.getString("catid");
Dal db = new Dal(this);
db.database();
db.open();
int count = db.count(catid);
String[] name = new String[count];
for (int i = 0; i < count; i++)
{
name[i] = db.Display(i, 3, catid);
}
setListAdapter(new MyAdapter(this, android.R.layout.simple_list_item_1, R.id.txt1, name));
list1 = (ListView) findViewById(R.id.list);
list1.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, final View view,
int position, long id) {
Intent i = new Intent(getApplicationContext(), Showdetale.class);
number_of_keys = String.valueOf(position + 1);
i.putExtra("key_number", number_of_keys);
startActivity(i);
}
});
}
private class MyAdapter extends ArrayAdapter<String> {
public MyAdapter(Context context, int resource, int textViewResurceid, String[] strings) {
super(context, resource, textViewResurceid, strings);
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater intflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View row = intflater.inflate(R.layout.list_item, parent, false);
String imageName = "a" + String.valueOf(position + 1);
int image_res_ID = getResources().getIdentifier(imageName, "drawable", getPackageName());
ImageView iv = (ImageView) row.findViewById(R.id.img1);
iv.setImageResource(image_res_ID);
return row;
}
}
}
Pleazzzzz HELPPPP MEEEEEE :(
I search evry site but i cant solve this