如何获取gridview的文本颜色,在我的应用程序中我使用了黑色,白色和红色来区分文本,现在我需要在onclick中获取文本的颜色,给我一些想法来获取溶液
感谢。
答案 0 :(得分:1)
将onItemClickListener设置为:
gridView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View view, int arg2,
long arg3) {
TextView tv = (TextView) view;
int color=tv.getCurrentTextColor();
}
});
答案 1 :(得分:0)
您可以在OnItemClick
textView.getCurrentTextColor();
答案 2 :(得分:0)
这将解决您的问题:
gridViewLocation=(GridView) findViewById(R.id.gridViewLocation);
现在设置适配器:
gridViewLocation.setAdapter(new GridViewAdapter(this,MOBILE_OS));
gridViewLocation.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View v,
int position, long id) {
TextView textView=(TextView) v.findViewById(R.id.grid_item_label);
textView.getCurrentTextColor();
}
});