- how to define the position of a alert dialog in view [closed]
- LayoutInflater inflater=getLayoutInflater();
- View view = inflater.inflate(R.layout.actionbarmain,null);
- view.setMinimumWidth(200);
- view.setMinimumHeight(400);
- AlertDialog.Builder alertDialog = new AlertDialog.Builder(this);
- alertDialog.setView(view);
- alertDialog.show();
- public class EditPropertyActivity extends Activity {
- /** Called when the activity is first created. */
- // @Override
- /*
- * (non-Javadoc)
- *
- * @see android.app.Activity#onCreate(android.os.Bundle)
- */
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- requestWindowFeature(Window.FEATURE_NO_TITLE);
- setContentView(R.layout.dialog);
- setTitle("");
- TextView propName = (TextView) findViewById(R.id.tv_propName);
- propName.setText(getIntent().getExtras().getString("prop_label"));
- final EditText ed_propValue = (EditText) findViewById(R.id.ed_propValue);
- ed_propValue.setText(value);
- if (tagName.equals("timeout")) {
- ed_propValue.setInputType(InputType.TYPE_CLASS_NUMBER);
- }
- Button btn_save = (Button) findViewById(R.id.btn_save);
- btn_save.setOnClickListener(new View.OnClickListener() {
- //onclick
- }
- }
- <activity
- android:name="EditPropertyActivity"
- android:theme="@android:style/Theme.Dialog" >
- </activity>
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:orientation="vertical" >
- <TextView
- android:id="@+id/tv_propName"
- android:layout_width="200dip"
- android:layout_height="wrap_content"
- android:layout_gravity="center"
- android:layout_marginBottom="10dip"
- android:layout_marginLeft="15dip"
- android:layout_marginRight="25dip"
- android:layout_marginTop="10dip"
- android:text="Medium Text"
- android:textAppearance="?android:attr/textAppearanceMedium" />
- <EditText
- android:id="@+id/ed_propValue"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:ems="10" >
- <requestFocus />
- </EditText>
- <LinearLayout
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_marginLeft="2dp"
- android:layout_marginRight="2dp"
- android:orientation="horizontal" >
- <Button
- android:id="@+id/btn_save"
- android:layout_width="0dip"
- android:layout_height="wrap_content"
- android:layout_weight="1"
- android:text="@string/lbl_btn_save" />
- <Button
- android:id="@+id/btn_cancel"
- android:layout_width="0dip"
- android:layout_height="wrap_content"
- android:layout_weight="1"
- android:text="@string/cancel" />
- </LinearLayout>
- </LinearLayout>
- <?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="fill_parent"
- android:orientation="vertical" >
- <Button
- android:id="@+id/btn1"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="test" />
- <Button
- android:id="@+id/btn2"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="test" />
- <Button
- android:id="@+id/btn3"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="test" />
- </LinearLayout>
- AlertDialog.Builder builder=new Builder(YourActivityName.this);
- LayoutInflater inflater=getLayoutInflater();
- View view=inflater.inflate(R.layout.testxml, null);
- builder.setView(view);
- builder.setTitle("New Project");
- builder.setMessage("knknknknknmknknknk");
- builder.setPositiveButton("ok", new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- }
- });
- builder.setNegativeButton("cancel", new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- }
- });
- builder.create();
- builder.show();