我正在经历一个错误。无法添加OnClickListener对象。这是以下代码。如何在Android中添加OnClickListener对象?
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState)
{
Activity act;
View rootView = inflater.inflate(R.layout.abc, container, false);
TextView tt=(TextView) rootView.findViewById(R.id.txt);
Button button=(Button) rootView.findViewById(R.id.btn1);
button.setOnClickListener(mFan); // Here i am getting the error //
View.OnClickListener mFan = new OnClickListener()
{
public void onClick(View v)
{
}
};
}
我在MFAN OnClickListener对象面对错误,
我得到MFAN的错误不能被解析为一个变量
所以,请帮助我,建议我一些好的解决方案
非常感谢,但您的第二个选项绝对正确。再次感谢。 – animation123