如何在Android的gridview的禁用项目 [英] how to disable item in gridview in android
本文介绍了如何在Android的gridview的禁用项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有是ImageView的我gridview.I要禁用它被点击android.I的GridView的我无法做到this.how要做到这一点当前项目/图像?
这里是一个code -
@覆盖
公共无效onItemClick(适配器视图<>为arg0,视图V,int无,长LG){
// TODO自动生成方法存根 最后AlertDialog.Builder警报=新AlertDialog.Builder(MainActivity.this);
ID =无; 最终的EditText输入=新的EditText(MainActivity.this);
alert.setView(输入); alert.setPositiveButton(检查,新DialogInterface.OnClickListener(){
公共无效的onClick(DialogInterface对话,诠释whichButton){ 字符串值= input.getText()的toString()。 AlertDialog.Builder报警1 =新AlertDialog.Builder(MainActivity.this); 如果(value.equalsIgnoreCase(国家[ID])){ //在这里,我想禁用项目
alert1.setPositiveButton(正确的,新DialogInterface.OnClickListener(){
公共无效的onClick(DialogInterface对话,诠释whichButton){ }
}); }
其他
{ }
}
}); alert.show();
}
});
解决方案
您需要一个定制的适配器。
覆盖的方法
ListAdapter.isEnabled(INT位置)
和覆盖ListAdapter.areAllitemsEnabled()返回false。
完全关闭点击,以及选择的图形在GridView控件的用户界面。
There is imageview in my gridview.I want to disable current item/image which is clicked in gridview of android.I am not able to do this.how to do this?? here is a code-
@Override
public void onItemClick(AdapterView<?> arg0, View v, int no,long lg) {
// TODO Auto-generated method stub
final AlertDialog.Builder alert = new AlertDialog.Builder(MainActivity.this);
id=no;
final EditText input = new EditText(MainActivity.this);
alert.setView(input);
alert.setPositiveButton("Check", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
String value = input.getText().toString();
AlertDialog.Builder alert1 = new AlertDialog.Builder(MainActivity.this);
if(value.equalsIgnoreCase(country[id])){
// here i want to disable item
alert1.setPositiveButton("Correct", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
}
});
}
else
{
}
}
});
alert.show();
}
});
解决方案
You need a custom adapter.
Override the methods
ListAdapter.isEnabled(int position)
and override ListAdapter.areAllitemsEnabled() to return false.
Completely disables clicking, as well as selection graphics in the UI for GridView.
这篇关于如何在Android的gridview的禁用项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文