Home | History | Annotate | Download | only in quicksearchbox
      1 /*
      2  * Copyright (C) 2010 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 package com.android.quicksearchbox;
     18 
     19 import android.app.Activity;
     20 import android.os.Bundle;
     21 import android.view.View;
     22 import android.view.Window;
     23 import android.widget.FrameLayout;
     24 import android.widget.TextView;
     25 
     26 /**
     27  * Activity that looks like a dialog window.
     28  */
     29 public abstract class DialogActivity extends Activity {
     30 
     31     protected TextView mTitleView;
     32     protected FrameLayout mContentFrame;
     33 
     34     @Override
     35     protected void onCreate(Bundle savedInstanceState) {
     36         super.onCreate(savedInstanceState);
     37         getWindow().requestFeature(Window.FEATURE_NO_TITLE);
     38         setContentView(R.layout.dialog_activity);
     39         mTitleView = (TextView) findViewById(R.id.alertTitle);
     40         mContentFrame = (FrameLayout) findViewById(R.id.content);
     41     }
     42 
     43     public void setHeading(int titleRes) {
     44         mTitleView.setText(titleRes);
     45     }
     46 
     47     public void setHeading(CharSequence title) {
     48         mTitleView.setText(title);
     49     }
     50 
     51     public void setDialogContent(int layoutRes) {
     52         mContentFrame.removeAllViews();
     53         getLayoutInflater().inflate(layoutRes, mContentFrame);
     54     }
     55 
     56     public void setDialogContent(View content) {
     57         mContentFrame.removeAllViews();
     58         mContentFrame.addView(content);
     59     }
     60 
     61     public View getDialogContent() {
     62         if (mContentFrame.getChildCount() > 0) {
     63             return mContentFrame.getChildAt(0);
     64         } else {
     65             return null;
     66         }
     67     }
     68 
     69 }
     70