I am new to Android. when I run my project, I got the following error:
Your content must have a ListView whose id attribute is 'android.R.id.list'
it crush on this line:
setContentView(R.layout.activity_main);
my activity_main.xml
<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"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.soft8.sql_test.MainActivity" >
<ListView
android:id="@+id/TheClient"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
</ListView>
</RelativeLayout>
and main class:
public class MainActivity extends ListActivity {
private ArrayList results = new ArrayList();
SQLController dbcon;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final ListView lv1 = (ListView) findViewById(R.id.TheClient);
dbcon = new SQLController(this);
dbcon.open();
dbcon.insertSomeItmes();
results = (ArrayList) dbcon.ReadData();
lv1.setAdapter(new CustomListAdapter(this, results));
dbcon.close();
}
Thank you.