我真的很陌生,android编程,实际上编程本身。 我正在创建一个具有选项卡的应用程序,并且在其中一个选项卡中,我想在其中添加listview。 我迷路了卡,请告知android创建listview内片段
public class TabActivityQueue extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View V = inflater.inflate(R.layout.activity_tab_activity_queue, container, false);
populateListView();
return V;
}
private void populateListView() {
// Create list of items
String[] myItems = {"Blue", "Green", "Purple", "Red"}; // Build Adapter
// TODO: CHANGE THE [[ to a less than, ]] to greater than.
ArrayAdapter<String> adapter = new ArrayAdapter<String> (TabActivityQueue,R.layout.da_items, myItems);
ListView list = (ListView) findViewById(R.id.listview1);
list.setAdapter(adapter);
}}
@Aniqi u能提供其中u卡? – 2014-09-02 07:45:18
@Aniqi去这个链接它可能会解决http://stackoverflow.com/questions/22512833/create-listview-in-fragment-android。也看看这个http://www.mysamplecode.com/2012/08/android-fragment-example.html – 2014-09-02 07:47:49