我正在經歷一個錯誤。無法添加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