Skip to content

Instantly share code, notes, and snippets.

@basharam
Created April 18, 2012 14:34
Show Gist options
  • Save basharam/2413989 to your computer and use it in GitHub Desktop.
Save basharam/2413989 to your computer and use it in GitHub Desktop.
How to show Activity as Dilaog without buttons in Android
public class ActivityasDlg extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activtyasdlg);
}
@Override
protected void onDestroy() {
finish();
super.onDestroy();
}
@Override
protected void onPause() {
Log.d(getClass().getName(),"pause" );
finish();
super.onPause();
}
}
// in layout folder
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@android:drawable/dialog_frame"
android:layout_gravity="center|center_vertical|fill_horizontal"
android:orientation="vertical" >
<TextView
android:id="@+id/textView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="QApp Upload Info"
android:gravity="center_horizontal"
android:padding="4dip"
android:textAppearance="?android:attr/textAppearanceLarge" />
<View
android:layout_width="fill_parent"
android:layout_height="1dip"
android:background="#fff"
/>
<TextView
android:padding="35dip"
android:id="@+id/textView2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_horizontal"
android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>
// add activty to manifest files
<activity android:name="com.ActivityasDlg" android:noHistory="true" android:screenOrientation="portrait" android:excludeFromRecents="true"></activity>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment