我正在製作一個應用程序並使用ListView的自定義適配器。它是在活動ListView彈出窗口
public class Adapter extends ArrayAdapter {
Context mContext;
int resourceID;
ArrayList<String> names;
public Adapter(Context context, int resource, ArrayList<String> objects) {
super(context, resource, objects);
this.mContext = context;
this.resourceID=resource;
this.names= objects;
}
@Override
public String getItem(int position) {
return names.get(position);
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View row = convertView;
LayoutInflater inflater = LayoutInflater.from(mContext);
row = inflater.inflate(resourceID, parent, false);
TextView text = (TextView) row.findViewById(R.id.text);
text.setText(names.get(position));
return row;
}
}
工作,我用這個代碼,使他們出現在活動
myNames= (ListView) findViewById(R.id.List);
adapter = new Adapter(this,R.layout.names_view, Current.Names);
myNames.setAdapter(adapter);
現在我想點擊一個按鈕,使同一列表出現在彈出窗口中,任何幫幫我?
一個彈出窗口是一個AlertDialog或你是什麼意思? –
我的意思是這個類PopupWindow試圖做多種方式,但它沒有工作 – Esraa