我要获取某个fragment里的控件,怎么获取?
H_eaven
2014-09-28
2 回答
public class ChatMainTabFragment extends Fragment { private Button btn1; private TextView tv1; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // TODO Auto-generated method stub View tab01View=inflater.inflate(R.layout.tab01, container,false); btn1=(Button) tab01View.findViewById(R.id.tab1_btn1); tv1=(TextView) tab01View.findViewById(R.id.tab1_tv1); btn1.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub tv1.setText("hello!I am first tab~"); } }); return tab01View; } }
这样就实现了操控tab界面中的控件了
举报
0/150
提交
取消