我有在其中扩展FragmentActivity
的类我将片段添加到布局中,如下所示
public class maincontrolActivity extends FragmentActivity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.maincontrol);
oUnit fragment = new oUnit();
fragmentTransaction.add(R.id.mainLayout,fragment, "MY_FRAG");
fragmentTransaction.commit();
}
}
Ounit 看起来像
public class oUnit extends Fragment {
View view = inflater.inflate(
R.layout.chemounit,
container,
false);
///// 我的其他代码
return view;
}
oCreateView
在Ounit
我尝试添加进度条
ProgressDialog connectionProgressDialog = new ProgressDialog( getActivity());
connectionProgressDialog.setCancelable(false);
connectionProgressDialog.setCanceledOnTouchOutside(false);
connectionProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
connectionProgressDialog.setMessage("Uploading Leads...");
connectionProgressDialog.show();
但它从不显示
我在这个片段列表中有我使用它的构造函数上下文的路径view.getContext()
我尝试显示AlertDialog
AlertDialog.Builder alert = new AlertDialog.Builder(v.getContext());
final EditText input = new EditText(v.getContext());
alert.setView(input);
alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
// Toast.makeText(getApplicationContext(), s_spin_text,
// Toast.LENGTH_SHORT).show();
}
});
alert.setNegativeButton("Cancel",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
dialog.cancel();
}
});
alert.show();
这个问题是因为这条线吗
View view = inflater.inflate(
R.layout.chemounit,
container,
false);
如是 ?如何更换它
最好的祝福