私の親アクティビティのダイアログを呼び出します。ダイアログは別のアクティビティにあります...アダプタ "setListAdapter(new ListViewAdapter(this));"を設定中にエラーが発生しました...いずれかのplzは私カスタムダイアログリストビューでの問題
に
package org.me.dailogfrmchildact;
/** Class Must extends with Dialog */
/** Implement onClickListener to dismiss dialog when OK Button is pressed */
public class CustomizeDialog extends Dialog implements OnClickListener {
Button okButton;
public CustomizeDialog(Context context) {
super(context);
/** 'Window.FEATURE_NO_TITLE' - Used to hide the title */
requestWindowFeature(Window.FEATURE_NO_TITLE);
/** Design the dialog in main.xml file */
setContentView(R.layout.main);
okButton = (Button) findViewById(R.id.OkButton);
okButton.setOnClickListener(this);
}
@Override
public void onClick(View v) {
/** When OK Button is clicked, dismiss the dialog */
if (v == okButton){
ListviewContent.add("sadas");
ListviewCount.add("dasasd");
setListAdapter(new ListViewAdapter(this));
}
}
private static ArrayList<String> ListviewContent = new ArrayList<String>();
private static ArrayList<String> ListviewCount = new ArrayList<String>();
private static class ListViewAdapter extends BaseAdapter {
private LayoutInflater mInflater;
public ListViewAdapter(Context context) {
mInflater = LayoutInflater.from(context);
}
public int getCount() {
return ListviewContent.size();
}
public Object getItem(int position) {
return position;
}
public String getCount(int position) {
return ListviewCount.get(position);
}
public String[] getSizeType(int position) {
String[] str = new String[2];
str[0] = ListviewContent.get(position);
str[1] = ListviewCount.get(position);
return str;
}
public long getItemId(int position) {
return position;
}
public View getView(int position, View convertView, ViewGroup parent) {
ListContent holder;
if (convertView == null) {
convertView = mInflater.inflate(R.layout.listviewinflate, null);
holder = new ListContent();
holder.text = (TextView) convertView.findViewById(R.id.TextView01);
holder.text.setCompoundDrawables(null, null, null, null);
holder.count = (TextView) convertView.findViewById(R.id.TextView02);
holder.count.setCompoundDrawables(null, null, null, null);
convertView.setTag(holder);
} else {
holder = (ListContent) convertView.getTag();
}
holder.text.setText(ListviewContent.get(position));
holder.count.setText(ListviewCount.get(position));
return convertView;
}
static class ListContent {
TextView text;
TextView count;
}
}
}
mainactivity.class
CustomizeDialog.classを支援することができます10
public CustomizeDialog(コンテキストコンテキスト){ super(コンテキスト); – jerith