想实现在ListFragment里面的ListView的item里面的Button的点击事件
来源:互联网 发布:mac上的三维软件 编辑:程序博客网 时间:2024/05/24 05:14
想实现在ListFragment里面的ListView的item里面的Button的点击事件
重写了BaseAdapter 然后再ListFragment中的onCreated()方法中setAdapter一直出错 求大神
重写了BaseAdapter 然后再ListFragment中的onCreated()方法中setAdapter一直出错 求大神
package com.example.cms.lizixiaoyuan.Adapter;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import com.example.cms.lizixiaoyuan.Activity.Function_Biaoqian;
import com.example.cms.lizixiaoyuan.R;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* Created by CMS on 2016/8/6.
*/
public class FunctionClassAdapter extends BaseAdapter {
private class ViewHolder{
ImageView f_c_rmnr_photo;
TextView f_c_rmnr_title;
TextView f_c_rmnr_bq;
TextView f_c_rmnr_text1;
TextView f_c_rmnr_text2;
TextView f_c_rmnr_text3;
TextView f_c_rmnr_num_comment;
TextView f_c_rmnr_num_like;
TextView f_c_rmnr_pf;
TextView f_c_rmnr_dbq;
TextView f_c_rmnr_author;
}
private List<Map<String, Object>> mAppList;
private LayoutInflater mInflater;
private Context mContext;
private String[] keyString;
private int[] valueViewID;
private ViewHolder holder=null;
public FunctionClassAdapter(Context c, List<Map<String, Object>> appList, int resource,
String[] from, int[] to) {
mContext = c;
mAppList = appList;
mInflater = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
keyString = new String[from.length];
valueViewID = new int[to.length];
System.arraycopy(from, 0, keyString, 0, from.length);
System.arraycopy(to, 0, valueViewID, 0, to.length);
}
@Override
public int getCount() {
return mAppList.size();
}
@Override
public Object getItem(int position) {
return mAppList.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView != null) {
holder = (ViewHolder) convertView.getTag();
} else {
convertView = mInflater.inflate(R.layout.f_c_list_item, null);
holder = new ViewHolder();
holder.f_c_rmnr_photo= (ImageView) convertView.findViewById(valueViewID[0]);
holder.f_c_rmnr_title= (TextView) convertView.findViewById(valueViewID[1]);
holder.f_c_rmnr_bq= (TextView) convertView.findViewById(valueViewID[2]);
holder.f_c_rmnr_text1= (TextView) convertView.findViewById(valueViewID[3]);
holder.f_c_rmnr_text2= (TextView) convertView.findViewById(valueViewID[4]);
holder.f_c_rmnr_text3= (TextView) convertView.findViewById(valueViewID[5]);
holder.f_c_rmnr_num_comment= (TextView) convertView.findViewById(valueViewID[6]);
holder.f_c_rmnr_num_like= (TextView) convertView.findViewById(valueViewID[7]);
holder.f_c_rmnr_pf= (TextView) convertView.findViewById(valueViewID[8]);
holder.f_c_rmnr_dbq= (TextView) convertView.findViewById(valueViewID[9]);
holder.f_c_rmnr_author= (TextView) convertView.findViewById(valueViewID[10]);
convertView.setTag(holder);
}
HashMap<String, Object> appInfo = (HashMap<String, Object>) mAppList.get(position);
if (appInfo != null) {
int f_c_rmnr_photo= (Integer) appInfo.get(keyString[0]);
String f_c_rmnr_title= (String) appInfo.get(keyString[1]);
String f_c_rmnr_bq= (String) appInfo.get(keyString[2]);
String f_c_rmnr_text1= (String) appInfo.get(keyString[3]);
String f_c_rmnr_text2= (String) appInfo.get(keyString[4]);
String f_c_rmnr_text3= (String) appInfo.get(keyString[5]);
String f_c_rmnr_num_comment= (String) appInfo.get(keyString[6]);
String f_c_rmnr_num_like= (String) appInfo.get(keyString[7]);
String f_c_rmnr_pf= (String) appInfo.get(keyString[8]);
String f_c_rmnr_dbq= (String) appInfo.get(keyString[9]);
String f_c_rmnr_author= (String) appInfo.get(keyString[10]);
holder.f_c_rmnr_photo.setImageResource(f_c_rmnr_photo); ///??????????????????????/
holder.f_c_rmnr_title.setText(f_c_rmnr_title);
holder.f_c_rmnr_bq.setText(f_c_rmnr_bq);
holder.f_c_rmnr_text1.setText(f_c_rmnr_text1);
holder.f_c_rmnr_text2.setText(f_c_rmnr_text2);
holder.f_c_rmnr_text3.setText(f_c_rmnr_text3);
holder.f_c_rmnr_num_comment.setText(f_c_rmnr_num_comment);
holder.f_c_rmnr_num_like.setText(f_c_rmnr_num_like);
holder.f_c_rmnr_pf.setText(f_c_rmnr_pf);
holder.f_c_rmnr_dbq.setText(f_c_rmnr_dbq);
holder.f_c_rmnr_author.setText(f_c_rmnr_author);
holder.f_c_rmnr_dbq.setOnClickListener(new bqListener(position));
}
return convertView;
}
class bqListener implements View.OnClickListener {
private int position;
bqListener(int pos) {
position = pos;
}
@Override
public void onClick(View v) {
Toast.makeText(mContext, "position"+position, Toast.LENGTH_SHORT).show();
}
}
/**
* 移动ListView中某一项的方法
* @param position
*/
public void removeItem(int position){
mAppList.remove(position);
this.notifyDataSetChanged();
}
}
0 0
- 想实现在ListFragment里面的ListView的item里面的Button的点击事件
- 想实现在ListFragment里面的ListView的item里面的Button的点击事件
- listview item里面的控件点击事件
- ListView里面添加Button之类可点击事件Item不可点击的处理方法
- listview 中的 item里面带有button按钮的点击实现方法
- 解决Listview的item和里面控件点击事件冲突
- Listview的item和里面控件点击事件冲突
- ListView item点击事件和里面的控件冲突失效
- listview的item里面有Button,并给其设置了点击事件,而且有效可点击,但是listview的item点击事件却失效了
- 自定义ListView里面的item不能点击
- 点击item获取里面的控件 ListView
- 自定义ListView里面的item不能点击
- Android基础:listview的item点击事件会使里面的Button也出现按压的效果
- 在ListView的adapter里面写了item的点击事件和整行的点击事件冲突
- 怎么让点击item的时候里面的button不会变换背景颜色,在点击具体的button时才变??
- android中ListView点击和ListView的item里面的button或ImageView不能同时生效的解决
- Android中ListView点击和ListView的item里面的Button或ImageView不能同时生效问题的解决
- android中ListView点击和ListView的item里面的button或ImageView不能同时生效的解决
- 在一个activity里面怎么监听别的xml的控件的事件
- 用 TableView 的代理方法添加的header点击第一个不触发事件,但是点击第二个header触发了第二组第一行的点击事件
- WebView如何打开pdf文件
- iOS后台保持连接,使用VOIP Socket方式,上传App Store会被拒绝么?
- Jason数据解析求解?
- 想实现在ListFragment里面的ListView的item里面的Button的点击事件
- android游戏开发中,能否给出一张路线图,让一圆点自动沿着路线移动?
- Android4.4中Email打开网页URL问题-欢迎大家来讨论
- android 5.1 api21以上怎么使用google zxing 扫描二维码
- 自定义menu的布局
- LBS教程---如何使用Android SDK进行开发
- PullToRefreshlibrary 打包XML报错。
- 第二天(就业班) html的引入、html常用标签、实体标签、超链接标签、图片标签、表格、框架标签、表单
- android 广播消息的内存怎么释放?