FragmentActivity
除了使用启动方法之外,还有其他方法可以调用方法Intents
吗?有人可以帮忙吗?
代码如下:
class MainActiviy extends Activiy{
//some code
//here i need to show a dialog
}
class MyDialog extends DialogFragment {
int mNum = 0;
static MyDialog newInstance(){
return new MyDialog();
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
//dialog view
Log.i("MyDialog", "onCreateview");
View v = inflater.inflate(R.layout.dialog, container, false);
TextView v1 = (TextView) v.findViewById(R.id.text);
v1.setText("dialog shown");
return v;
}
}
public class DialogActivity extends FragmentActivity{
DialogFragment dialogfragment;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
void show(){
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
Fragment f = getSupportFragmentManager().findFragmentByTag("dialog");
if(f != null){
ft.remove(f);
}
dialogfragment = MyDialog.newInstance();
dialogfragment.setCancelable(false);
dialogfragment.show(ft, "dialog");
dialogfragment.setStyle(DialogFragment.STYLE_NO_TITLE, android.R.style.Theme_Holo_Light_Dialog);
}
}
有没有其他方法可以从另一个 Activity 类中调用该
show()
方法?DialogActivity