布局文件
agg_attack_text_list.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView android:id="@+id/text_attack_text_list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="所需物品"/>
<ListView android:id="@+id/list_attack_text_list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/transparent"/>
</LinearLayout>
JAVA代码
public class AggKillGhostGoodsListDlg extends AlertDialog {
private final Context mContex;
TextView mMessage = null;
ListView mListView = null;
MyListAdapter mMyAdapter = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
//此处仅一个简单的TextView,可以扩展到自定义xml里面
LayoutInflater factory = LayoutInflater.from(mContex);
LinearLayout layout =(LinearLayout) factory.inflate(R.layout.agg_attack_text_list, null);
setTitle(mContex.getResources().getString(R.string.kill_ghost_need_goods));
setButton(mContex.getResources().getString(R.string.OkButton), new OnClickListener() {
public void onClick(DialogInterface dialogInterface, int i) {
//To change body of implemented methods use File | Settings | File Templates.
Log.d(TAG, "onClick");
}
});
setView(layout);
super.onCreate(savedInstanceState);
mMessage = (TextView) findViewById(R.id.text_attack_text_list);//new ListView(mContex);
mListView = (ListView) findViewById(R.id.list_attack_text_list);//new ListView(mContex);
mMyAdapter = new MyListAdapter(mContex, R.layout.agg_box_open_dlg, mAllGoodsList);
mListView.setAdapter(mMyAdapter);
}
}