我需要在我的列表視圖中顯示圖像和文本時,當我單擊按鈕搜索,但它給我一個錯誤在我的setListAdapter(new MobileArrayAdapter(this, PNames,PImages));
..我有兩個類。 當我顯示onformLoad它的工作,但現在我需要用一個按鈕移到,在這裏我的兩個類新來顯示它:構造函數ArrayAdapter onclick問題
B_KZN.setOnClickListener(new View .OnClickListener() {
@Override
public void onClick(View Kv) {
// TODO Auto-generated method stub
JSONObject json = JSONfunctions.getJSONfromURL("http://10.0.2.2/php/p.php");
try{
JSONArray earthquakes = json.getJSONArray("SKZN");
for(int i=0;i<earthquakes.length();i++){
JSONObject e = earthquakes.getJSONObject(i);
String BookName = e.getString("P_City");
PNames.add(BookName);
String BookImg = e.getString("Pname");
PImages.add(BookImg);
}
}catch(JSONException e){
Log.e("log_tag", "Error parsing data "+e.toString());
}
setListAdapter(new MobileArrayAdapter(this, PNames,PImages));
我的第二類,:
public class MobileArrayAdapter extends ArrayAdapter<String> {
private final Context context;
private final String[] myBookNamelist = null;
private ArrayList<String> MyP = new ArrayList<String>();
private ArrayList<String> myPurl = new ArrayList<String>();
public MobileArrayAdapter(Context context,ArrayList<String> Bname,ArrayList<String> BUrl) {
super(context, R.layout.list_mobile, Bname);
this.context = context;
this.MyP = Bname;
this.myPurl = BUrl;
}
這裏我的錯誤:The constructor MobileArrayAdapter(new View.OnClickListener(){}, ArrayList<String>, ArrayList<String>) is undefined
。 .. 它顯示我紅線。
方式並重新說出來:p – Blundell
@布倫德爾我請你原諒?我獨自寫了這篇文章,同時你寫了你的。不幸的是,SO不會顯示「秒前」,只有幾分鐘。你可能會看到我們的兩個答案相差約5秒。我不喜歡別人複製我的答案,而我自己也不這樣做。 –
它也顯示編輯也是你的答案,我看到你的原始答案,然後你的變化。別擔心 – Blundell