這是活動如何啓用頁腳可點擊並設置監聽器?
private View footer;
private Button btnmore;
linear = (LinearLayout) findViewById(R.id.layout_content);
linear.setVisibility(View.VISIBLE);
LayoutInflater liInflater = (LayoutInflater)this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
linear.addView(liInflater.inflate(R.layout.main_particularcategoryallnewslist, null));
linear.addView(liInflater.inflate(R.layout.main_particularcategoryallnewslistfv, null));
footer = (View)getLayoutInflater().inflate(R.layout.main_particularcategoryallnewslistfv, null);
btnmore = (Button)findViewById(R.id.btn_more);
ListView lv = (ListView) findViewById(android.R.id.list);
SimpleAdapter adapter = new SimpleAdapter(this, fillMaps,
R.layout.main_particularcategoryallnewslist, from, to);
lv.addFooterView(footer); <-- how to set footer being clickable?
lv.setAdapter(adapter);
在頁腳,我有一個按鈕,但我在其上設置監聽器也沒有反應,我覺得頁腳必須啓用是單擊,然後方能按鈕之中點擊。
lv.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
Intent intent = new Intent(Main_ParticularCategoryAllNews.this,
Main_ParticularNewsDetail.class);
bundle = new Bundle();
bundle.putInt("newsid", newsid[arg2]);
intent.putExtras(bundle);
startActivity(intent);
}
});
btnmore.setOnClickListener(new OnClickListener() {
public void onClick(View arg0) {
if (isOnline() == true) {
linear2.setVisibility(View.VISIBLE);
AlphaAnimation alpha = new AlphaAnimation(0.5F, 0.5F);
alpha.setDuration(15);
alpha.setFillAfter(true);
linear.startAnimation(alpha);
btnrefresh.setVisibility(View.INVISIBLE);
webservice.UpdateMoreCatNews(catnewsid);
int secondsDelayed = 3;
new Handler().postDelayed(new Runnable() {
public void run() {
startActivity(new Intent(Main_ParticularCategoryAllNews.this,
Main_AllLatestNews.class));
finish();
}
}, secondsDelayed * 1000);
} else {
toast = Toast
.makeText(
Main_ParticularCategoryAllNews.this,
"Your device is not connect to internet, fail to update news!",
Toast.LENGTH_SHORT);
toast.setGravity(Gravity.CENTER_VERTICAL
| Gravity.CENTER_HORIZONTAL, 0, 0);
toast.show();
}
}
});
如何在頁腳被點擊時設置監聽器?
什麼是頁腳? – user370305
頁腳出現在列表視圖的最後一個元素的下方 –