我想在popup
窗口中添加標題,該窗口應該在彈出列表中修復。只有彈出列表應該是scroll
。我怎樣才能做到這一點?請建議我。在彈出窗口中添加標題
public PopupWindow popupWindowcountry() {
PopupWindow popupWindow = new PopupWindow(this);
ListView listView = new ListView(this);
listView.setAdapter(Country_Padpter);
popupWindow.setFocusable(true);
popupWindow.setWidth((int) (getWindowManager().getDefaultDisplay()
.getWidth()/2.2));
popupWindow.setHeight(515);
popupWindow.setContentView(listView);
return popupWindow;
}
private class PopupWindows_Adpter extends BaseAdapter {
@Override
public int getCount() {
return Country_arrayList.size();
}
@Override
public Object getItem(int position) {
return null;
}
@Override
public long getItemId(int position) {
return 0;
}
@SuppressWarnings("unused")
@Override
public View getView(int position, View convertView, ViewGroup parent) {
// View grid;
LayoutInflater inflater = (LayoutInflater) DNPActivity.this
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = null;
if (convertView == null) {
convertView = new View(DNPActivity.this);
convertView = inflater
.inflate(R.layout.country_popup_row, null);
final TextView textView = (TextView) convertView
.findViewById(R.id.item_txt_popup_row);
final LinearLayout layout = (LinearLayout) convertView
.findViewById(R.id.popup_ll);
// final TextView header=(TextView)
// convertView.findViewById(R.id.item_txt_popup_header);
textView.setText(Country_arrayList.get(position).getName());
textView.setBackgroundColor(Color.WHITE);
textView.setTextColor(Color.BLACK);
textView.setTextSize(18);
textView.setPadding(15, 10, 10, 10);
layout.setOnClickListener(new OnClickListener() {
@SuppressLint("ShowToast")
@Override
public void onClick(View v) {
String selectedtext = textView.getText().toString();
Toast.makeText(DNPActivity.this, selectedtext,
Toast.LENGTH_LONG).show();
country_selected_txt = selectedtext;
tvtotalnewspapernumber.setText(country_selected_txt);
popupWindowcountry.dismiss();
new FilterAsync().execute();
}
});
} else {
convertView = (View) convertView;
}
return convertView;
}
}
使用'addHeaderView'爲ListView添加標題 –