我使用片段,当我单击编辑文本时,会显示带有特殊键盘的布局(许多按钮可单击),但我找不到检测按钮单击的正确方法
这是 onCreateView 代码:
public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState)
{
View view = inflater.inflate(R.layout.fragment_rsslist_overview,container, false);
try {
setKeys();
} catch (Exception e) {
Log.w(getClass().getName(), e.toString());
}
//
return view;
}
这是 setKeys 代码:(我在 mBSpace 按钮上尝试了很多东西)
public void setKeys() {
mWindowWidth = getActivity().getWindowManager().getDefaultDisplay().getWidth(); // getting
// window
// height
// getting ids from xml files
mB[0] = (Button) getActivity().findViewById(R.id.xA);
mB[1] = (Button) getActivity().findViewById(R.id.xB);
mB[2] = (Button) getActivity().findViewById(R.id.xC);
mB[3] = (Button) getActivity().findViewById(R.id.xD);
mB[4] = (Button) getActivity().findViewById(R.id.xE);
mB[5] = (Button) getActivity().findViewById(R.id.xF);
mB[6] = (Button) getActivity().findViewById(R.id.xG);
mB[7] = (Button) getActivity().findViewById(R.id.xH);
mB[8] = (Button) getActivity().findViewById(R.id.xI);
mB[9] = (Button) getActivity().findViewById(R.id.xJ);
mB[10] = (Button) getActivity().findViewById(R.id.xK);
mB[11] = (Button) getActivity().findViewById(R.id.xL);
mB[12] = (Button) getActivity().findViewById(R.id.xM);
mB[13] = (Button) getActivity().findViewById(R.id.xN);
mB[14] = (Button) getActivity().findViewById(R.id.xO);
mB[15] = (Button) getActivity().findViewById(R.id.xP);
mB[16] = (Button) getActivity().findViewById(R.id.xQ);
mB[17] = (Button) getActivity().findViewById(R.id.xR);
mB[18] = (Button) getActivity().findViewById(R.id.xS);
mB[19] = (Button) getActivity().findViewById(R.id.xT);
mB[20] = (Button) getActivity().findViewById(R.id.xU);
mB[21] = (Button) getActivity().findViewById(R.id.xV);
mB[22] = (Button) getActivity().findViewById(R.id.xW);
mB[23] = (Button) getActivity().findViewById(R.id.xX);
mB[24] = (Button) getActivity().findViewById(R.id.xY);
mB[25] = (Button) getActivity().findViewById(R.id.xZ);
mB[26] = (Button) getActivity().findViewById(R.id.xS1);
mB[27] = (Button) getActivity().findViewById(R.id.xS2);
mB[28] = (Button) getActivity().findViewById(R.id.xS3);
mB[29] = (Button) getActivity().findViewById(R.id.xS4);
mB[30] = (Button) getActivity().findViewById(R.id.xS5);
mB[31] = (Button) getActivity().findViewById(R.id.xS6);
mBSpace = (Button) getActivity().findViewById(R.id.xSpace);
mBdone = (Button) getActivity().findViewById(R.id.xDone);
mBChange = (Button) getActivity().findViewById(R.id.xChange);
mBack = (Button) getActivity().findViewById(R.id.xBack);
mNum = (Button) getActivity().findViewById(R.id.xNum);
// for (int i = 0; i < mB.length; i++)
mBSpace.setOnClickListener( this);
/*
mBSpace.setOnClickListener( new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
edittext_onClick(v );
}
});
*/
/*
mB[i].setOnClickListener( this);
mBSpace.setOnClickListener( this);
mBdone.setOnClickListener( this);
mBack.setOnClickListener( this);
mBChange.setOnClickListener( this);
mNum.setOnClickListener( this);
// mNum.setOnClickListener( this);
*/
}
有人知道他正确的语法对此做了什么吗?我尝试将 setkey() 调用为:
public void onActivityCreated (Bundle savedInstanceState){
setKeys();
super.onActivityCreated(savedInstanceState);
}
我没有错误,但也没有点击检测......提前谢谢......