匿名用户
1级
2015-08-19 回答
ListView可以通过addFooterView添加控件,用下面代码:
public class MyListViewActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
final Button button = new Button(this);
button.setText("Change To MyListView2");
final ListView listview = new ListView(this);
LinearLayout layout = new LinearLayout(MyListViewActivity.this);
layout.setOrientation(LinearLayout.HORIZONTAL);
layout.addView(button);
listview.addFooterView(layout);
listview.setAdapter(new ArrayAdapter(this, android.R.layout.simple_expandable_list_item_1, getData()));
addContentView(listview,new LayoutParams(LayoutParams.WRAP_CON