Dies ist mein Code in der HaupttätigkeitListActivity Fehler: „Leider Ihre App gestoppt“
public class MainActivity extends ListActivity {
private String [] mainScreenList = {"Portal","Settings","Help","About"};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ArrayAdapter<String> mainScreen = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_activated_1, android.R.id.text1,mainScreenList);
ListView lv = (ListView) findViewById(R.id.listView);
lv.setAdapter(mainScreen);
}
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
super.onListItemClick(l, v, position, id);
Object o = this.getListAdapter().getItem(position);
String pen = o.toString();
Toast.makeText(this, "You have chosen the pen: " + " " + pen, Toast.LENGTH_LONG).show();
//get selected items
/* if(position==0)
{
Intent i = new Intent(this, DataEntryActivity.class);
startActivity(i);
}else if(position==1)
{
Intent i = new Intent(this, DataEntryActivity.class);
startActivity(i);
}else if(position==2)
{
Intent i = new Intent(this, DataEntryActivity.class);
startActivity(i);
}else if(position==3)
{
Intent i = new Intent(this, DataEntryActivity.class);
startActivity(i);
}*/
}
}
Im Moment habe ich nur versuche, den Namen der Listenansicht Artikel zu zeigen, ausgewählt.
Dies ist der XML-Code
<?xml version="1.0" encoding="utf-8"?>
<ListView
android:id="@android:id/list"
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:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context="com.example.bernine.practicalsessions.MainActivity">
<ListView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/listView"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
/>
</ListView>
Wenn die App läuft sie sagt: "Leider ist die App zum Stillstand gekommen ist."
Beitrag Fehlerprotokoll .. –
benötigen Fehlerprotokoll .. – Mohan
Listview innerhalb Listview .. ???? – Dinash