private LinearLayout layout;
login_button.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View arg0)
{
layout = (LinearLayout) getLayoutInflater().inflate(R.layout.login, null);
Builder builder = new Builder(context);
builder.setIcon(R.drawable.icon);
builder.setTitle(R.string.login);
builder.setView(layout);
builder.setPositiveButton(R.string.submit, new DialogInterface.OnClickListener()
{
@Override
public void onClick(DialogInterface dialog, int which)
{
EditText text = (EditText) layout.findViewById(R.id.login_name);
String name = text.getText().toString();
Log.v("------------------",name);
}
});
builder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener()
{
@Override
public void onClick(DialogInterface dialog, int which)
{
}
});
dialogs = builder.create();
dialogs.show();
}
});
xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:id="@+id/big_layout">
<LinearLayout android:layout_width="fill_parent"
android:orientation="horizontal" android:layout_height="wrap_content"
android:id="@+id/linearLayout1" android:layout_marginLeft="20dp"
android:layout_marginRight="20dp">
<TextView android:text="@string/login_name" android:id="@+id/textView1"
android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView>
<EditText android:hint="@string/login_name_hint" android:id="@+id/login_name"
android:layout_width="fill_parent" android:layout_height="wrap_content"></EditText>
</LinearLayout>
<LinearLayout android:layout_width="fill_parent"
android:orientation="horizontal" android:layout_height="wrap_content"
android:id="@+id/linearLayout1" android:layout_marginLeft="20dp"
android:layout_marginTop="10dp" android:layout_marginRight="20dp">
<TextView android:text="@string/login_pass" android:id="@+id/textView1"
android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView>
<EditText android:hint="@string/login_pass_hint" android:id="@+id/login_name"
android:layout_width="fill_parent" android:layout_height="wrap_content"></EditText>
</LinearLayout>
</LinearLayout>
login_button.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View arg0)
{
layout = (LinearLayout) getLayoutInflater().inflate(R.layout.login, null);
Builder builder = new Builder(context);
builder.setIcon(R.drawable.icon);
builder.setTitle(R.string.login);
builder.setView(layout);
builder.setPositiveButton(R.string.submit, new DialogInterface.OnClickListener()
{
@Override
public void onClick(DialogInterface dialog, int which)
{
EditText text = (EditText) layout.findViewById(R.id.login_name);
String name = text.getText().toString();
Log.v("------------------",name);
}
});
builder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener()
{
@Override
public void onClick(DialogInterface dialog, int which)
{
}
});
dialogs = builder.create();
dialogs.show();
}
});
xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:id="@+id/big_layout">
<LinearLayout android:layout_width="fill_parent"
android:orientation="horizontal" android:layout_height="wrap_content"
android:id="@+id/linearLayout1" android:layout_marginLeft="20dp"
android:layout_marginRight="20dp">
<TextView android:text="@string/login_name" android:id="@+id/textView1"
android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView>
<EditText android:hint="@string/login_name_hint" android:id="@+id/login_name"
android:layout_width="fill_parent" android:layout_height="wrap_content"></EditText>
</LinearLayout>
<LinearLayout android:layout_width="fill_parent"
android:orientation="horizontal" android:layout_height="wrap_content"
android:id="@+id/linearLayout1" android:layout_marginLeft="20dp"
android:layout_marginTop="10dp" android:layout_marginRight="20dp">
<TextView android:text="@string/login_pass" android:id="@+id/textView1"
android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView>
<EditText android:hint="@string/login_pass_hint" android:id="@+id/login_name"
android:layout_width="fill_parent" android:layout_height="wrap_content"></EditText>
</LinearLayout>
</LinearLayout>