我正在尝试将RadioButtton
放入GridView
。我想点击单选按钮导航到另一个Activity
。但那并没有发生。
RadioButtton
的代码:
package login.pkg;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.RadioButton;
import android.widget.TextView;
public class Admin_view_users extends BaseAdapter
{
public OnClickListener monClick;
Context mContext;
private String [] id = {“S001″,”S002″,”S003″,”S004″};
private String [] name={“Ameya”,”Anukta”,”Ankita”,”Ashish”};
String[] meter_no = new String[]{“M10001″,”M10012″,”M10002″,”M10123″,”M10003″,”M10004″};
private String[] acc_type= {“user”,”user”,”user”,”user”};
private LayoutInflater mInflater;
public Admin_view_users(Context c)
{
mContext=c;
mInflater = LayoutInflater.from(c);
}
public void setOnClickListener(OnClickListener listener) {
monClick = listener;
// RadioButton rad = new RadioButton(newAdmin2);
}
public int getCount()
{
return id.length;
}
public Object getItem(int position)
{
return position;
}
public long getItemId(int position)
{
return position;
}
public View getView(int position, View convertView, ViewGroup parent)
{
ViewHolder holder=null;
if(convertView==null)
{
convertView = mInflater.inflate(R.layout.customgrid,
parent,false);
holder = new ViewHolder();
holder.txtId=(TextView)convertView.findViewById(R.id.txtId);
holder.txtId.setPadding(15, 10,10 , 10);
holder.txtName=(TextView)convertView.findViewById(R.id.txtName);
holder.txtName.setPadding(15, 10, 20, 10);
holder.acc_type=(TextView)convertView.findViewById(R.id.txtEmail);
holder.acc_type.setPadding(15, 10, 40, 10);
//holder.rad = (RadioButton)convertView.findViewById(R.id.radioButton1);
if(position==0)
{
convertView.setTag(holder);
}
}
else
{
holder = (ViewHolder) convertView.getTag();
}
holder.txtId.setText(id[position]);
holder.txtName.setText(name[position]);
holder.acc_type.setText(acc_type[position]);
// RadioButton rb= new RadioButton(newAdmin2);
return convertView;
}
static class ViewHolder
{
TextView txtId;
TextView txtName;
TextView acc_type;
RadioButton rad;
}
}
建议我这样做..
答案 0 :(得分:0)
不要使用RadioButton,因为它会让用户感到困惑 - RadioButtons用于选择众多选项中的一个。最好试试Button或ImageButton。