这是代码,这将打开一个带有名称的列表,但它在一个新窗口中。我想要做的是把这个列表放在主窗口上。我能做些什么?
public class MainActivity extends ListActivity {
String []name={"bill","gorg"};
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//setContentView(R.layout.activity_main);
setListAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1,name));
}
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
// TODO Auto-generated method stub
super.onListItemClick(l, v, position, id);
Object o=this.getListAdapter().getItem(position);
String keybord= o.toString();
Toast.makeText(this, "you are select "+keybord, Toast.LENGTH_LONG).show();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
}