我正在尝试制作一个列出所有英雄联盟冠军的 ListView。
我目前的问题是,现在只有列表视图本身不会显示在屏幕上并且无法弄清楚原因。
这是我的 MainActivity.java
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
这是我的冠军列表活动:
public class champListActivity extends ListActivity {
@Override
public void onCreate(Bundle fdsa) {
super.onCreate(fdsa);
ArrayAdapter<Champ> aa;
ArrayList<Champ> champList = new ArrayList<Champ>();
ListView listView = (ListView) findViewById(R.id.ChampListView);
// I SKIPPED THE CODE CONTAINING THE ADDING OF THE CHAMPIONS
// TO THE LIST BECAUSE ITS TOO LONG AND ALREADY RIGHT BECAUSE IT
// WORKED BEFORE AND I HAVENT CHANGED IT
int layoutID = android.R.layout.simple_list_item_1;
aa = new ArrayAdapter<Champ>(this, layoutID, champList);
listView.setAdapter(aa);
}
@Override
public void onListItemClick(ListView l, View v, int position, long id) {
super.onListItemClick(l,v,position,id);
Champ selChamp = (Champ) getListAdapter().getItem(position);
String champURL = selChamp.getLink();
Intent intent = new Intent(this,webViewActivity.class);
intent.putExtra("url", champURL);
startActivity(intent);
}