-1
我想創建「ListActivity」,但我無法看到輸出列表。我使用了人員代碼。而且,我在下面的代碼中沒有出現任何錯誤。請幫助解決這個問題。android listactivity
package com.wordpress.sree7k7;
import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
公共類菜單擴展ListActivity {
String classes[]={ "MainActivity", "example1","example2",
"example3","example4","example5","example6"};
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setListAdapter(new ArrayAdapter<String>(Menu.this, android.R.layout.simple_expandable_list_item_1));
}@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
// TODO Auto-generated method stub
super.onListItemClick(l, v, position, id);
String cheese = classes[position];
try {
Class ourClass = Class.forName("com.wordpress.sree7k7.Menu"+ cheese);
Intent ourIntent= new Intent(Menu.this, ourClass);
startActivity(ourIntent);
}catch(ClassNotFoundException e){
e.printStackTrace();
}
}
}