我正在开发一个应用程序,在其中我需要将徽标左对齐,然后选择右侧的类别列表。因此,我所拥有的是图像视图中的标志,它位于线性布局中,然后向LinearLayout添加一个ListView,以便它们可以在同一个活动上。当我尝试运行它时,出现意外停止的错误。带Imageview和列表视图的LinearLayout
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Commands.setText("Commands");
LinearLayout LL = new LinearLayout(this);
ImageView Logo = (ImageView)findViewById(0x7f020000);
Logo.setImageDrawable(getResources().getDrawable(android.R.drawable.ic_menu_myplaces));
ListView Cats = new ListView(this);
String Categories[] = new String[3];
Categories[0] = "Hardware";
Categories[1] = "Language";
Categories[2] = "Libraries";
ArrayAdapter<String> list = new ArrayAdapter<String>(this, 0, 2, Categories);
Cats.setAdapter(list);
LL.addView(Logo);
LL.addView(Cats);
setContentView(LL);
}
任何帮助,我真的很困惑