L
Luser_k
Neues Mitglied
- 2
Hi,
ich benötige Hilfe, bin ein Beginner.
Ich habe mittels ListActivity eine Liste erstellt.
Wenn ich einen Eintrag auswähle, dann soll durch ein Intent
eine neue Activity gestartet werden.
Fehlermeldung: Die Anwendung wird geschlossen.
Wo ist der Fehler? Ich sehe keine Fehler
listActivity: Start-Activity
showChoice: Activity, das nach der Auswahl angezeigt werden soll
main.xml
ich benötige Hilfe, bin ein Beginner.
Ich habe mittels ListActivity eine Liste erstellt.
Wenn ich einen Eintrag auswähle, dann soll durch ein Intent
eine neue Activity gestartet werden.
Fehlermeldung: Die Anwendung wird geschlossen.
Wo ist der Fehler? Ich sehe keine Fehler
listActivity: Start-Activity
Code:
package de.listing.app;
import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListAdapter;
import android.widget.ListView;
public class listActivity extends ListActivity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setTitle(R.string.app_name);
getListView().setTextFilterEnabled(true);
showData();
}
private void showData(){
String[] months = new String[]{"january","february","march","april","may","june","july","august","september","october","november","december"};
ListAdapter monthAdapter = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,months);
setListAdapter(monthAdapter);
}
protected void onListItemClick(ListView liste,View view,int position,long id){
super.onListItemClick(liste, view, position, id);
Intent intent = new Intent();
intent.setClass(listActivity.this,
showChoice.class);
startActivity(intent);
finish();
}
}
Code:
package de.listing.app;
import android.app.Activity;
import android.os.Bundle;
public class showChoice extends Activity{
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}
main.xml
Code:
<?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"
>
</LinearLayout>