海蘭,我有這樣的代碼在我的片段:如何更改運行中的片段?
public View onCreateView(LayoutInflater inflater,ViewGroup container,Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fr_menu,container,false);
final ViewGroup dismissableContainer = (ViewGroup)view.findViewById(R.id.dismissable_container);
for (int i = 0; i < 3; i++) {
final Button dismissableButton = new Button(getActivity());
dismissableButton.setLayoutParams(new ViewGroup.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
dismissableButton.setText("Button " + (i + 1));
dismissableContainer.addView(dismissableButton);
}
return view;
}
在同一個片段我有從外面
public void sendObject(MyObject t){
Button b=new Button(getActivity());
b.setText(t.getNum_tav());
// Now I want to put **b** under button1 button2 and button3
}
的方法使用SendObject接收對象的方法...如何我改變了片段? 我必須把按鈕與其他3個按鈕的
讓dismissableContainer一個字段,然後只要你需要添加。 – dymmeh 2013-04-26 20:51:47
同樣的問題,看下面 – Dom 2013-04-26 20:57:27
即時通訊假設你正試圖修改在不同線程的視圖 – dymmeh 2013-04-26 21:05:25