以编程方式添加到 GridView 中的按钮总数取决于字长。每个按钮都包含一个单词的字母,我想在使用标签单击按钮时获取该字母,我该如何获取?这是代码:
public View getView(final int position, View convertView, ViewGroup arg2) {
View v = convertView;
if (v == null)
{
LayoutInflater vi = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = vi.inflate(R.layout.buttonlist, null);
}
final Button btn= (Button)v.findViewById(R.id.letterbtn);
btn.setText(word[position]+"");
btn.setOnClickListener(new OnClickListener(){
public void onClick(View v)
{
btn.setTag(btn);
Object tag=btn.getTag();
btn.setVisibility(View.GONE);
function(position);
}
});