我正在制作一个应用程序并使用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