创建了两个TextView并调用方法registerForContextMenu方法,称为@override 方法,onCreateContextMenu但是当我单击textViews它时,按照程序不起作用。这可能是什么原因?
TextView color,size;
final int COLOR_RED = 1;
final int COLOR_BLUE = 2;
final int SIZE_26 = 26;
final int SIZE_30 = 30;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
color = (TextView)findViewById(R.id.color);
size = (TextView)findViewById(R.id.size);
Log.d("nimae","ishla");
registerForContextMenu(color);
registerForContextMenu(size);
}
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo)
{
switch (v.getId()){
case R.id.color:
menu.add(0,COLOR_RED,0,"Qizil");
menu.add(0,COLOR_BLUE,0,"Ko`k");
break;
case R.id.size:
menu.add(0,SIZE_26,0,"26 size");
menu.add(0,SIZE_30,0,"30 size");
break;
}
}
MYYA
慕标琳琳
相关分类