Problem showing an Activity as Dialog without Title & as an Activity too

Discussion in 'Android Lounge' started by AllTimeProg, Sep 4, 2012.

  1. AllTimeProg

    AllTimeProg New Member

    Sep 4, 2012
    I have an Activity (ExpandListActivity) which in one cas want to show as a Dialog and in other situation want to show as an Activity. The layout of ExpandListActivity has a TextView & ExpandList in a LinearLayout. When I show it as Dialog I want to remove the TitleBar & TextView from the layout, otherwise want both of them.
    I tried setting Theme of ExpandListActivity as Dialog in manifest file, but then am not able to set the theme back to normal when am showing it as an Activity.
    I removed Dialog Theme from manifest, and added requestWindowFeature (Window.FEATURE_NO_TITLE);, for the Dialog case, this gives me RuntimeException on this line. Added code to remove the TextView, but that also doesn't work.
    My code is as follows :
    ExpandListActivity is the Activity that I want to call as a Dialog &/or as an Activity :
    Code (Text):
    2. @Overridepublic void onCreate(Bundle savedInstanceState) {
    3. Intent sender = getIntent();
    4. boolean fDialogMode = sender.getBooleanExtra("dialogMode", false);
    5. Log.i("ELA", "For Dialog : " + fDialogMode);
    6. /*
    7. // If in Dialog mode,
    8. if (fDialogMode) {
    9. this.requestWindowFeature(Window.FEATURE_NO_TITLE);
    10. } else {
    11. super.setTheme(;
    12. }*/
    14. super.onCreate(savedInstanceState);
    15. //setContentView(R.layout.expand_list_layout);
    16. //TextView tv = (TextView) findViewById(;
    17. if (fDialogMode) {
    18. requestWindowFeature(Window.FEATURE_NO_TITLE);
    19. setContentView(R.layout.expand_list_layout);
    20. } else {
    21. ViewGroup vg = (ViewGroup) findViewById(;
    22. //vg.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
    23. ViewGroup.inflate(ExpandListActivity.this, R.layout.expand_list_layout, vg);
    24. //TextView tv = (TextView) vg.findViewById(;
    25. //tv.setText("Helpline");
    26. }
    Activity from which I call it as an Activity :
    Code (Text):
    3. Intent intent1 = null;
    4. intent1 = new Intent(Mumbai77Activity.this, HelplineActivity.class);
    5. intent1.putExtra("dialogMode", false);
    6. intent1.putStringArrayListExtra("lines", lines);

    Activity from which I call it as a Dialog :

    Intent intent1 =new Intent(PincodesActivity.this, ExpandListActivity.class);
    Code (Text):
    2. intent1.putExtra("dialogMode", true);
    3. intent1.putStringArrayListExtra("lines", lines);

    Can anyone help me out with this problem. Am stuck from 2 days with this problem. Any help is highly appreciated. I am new in this forum, not used to posting code here, so maybe some code is not in proepr format.


Share This Page