mirror of
https://github.com/moparisthebest/Yaaic
synced 2024-11-23 01:12:17 -05:00
Only enable the "Add" button when the alias input field is non-empty.
This commit is contained in:
parent
288a1a9093
commit
8c5af16b29
@ -22,12 +22,12 @@
|
|||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:singleLine="true"
|
android:singleLine="true"
|
||||||
android:text=""
|
|
||||||
android:layout_weight="1" />
|
android:layout_weight="1" />
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/add"
|
android:id="@+id/add"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:enabled="false"
|
||||||
android:text="Add" />
|
android:text="Add" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
@ -10,6 +10,8 @@ import android.app.AlertDialog;
|
|||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.text.Editable;
|
||||||
|
import android.text.TextWatcher;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.Window;
|
import android.view.Window;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
@ -20,11 +22,12 @@ import android.widget.EditText;
|
|||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
import android.widget.AdapterView.OnItemClickListener;
|
import android.widget.AdapterView.OnItemClickListener;
|
||||||
|
|
||||||
public class AddAliasActivity extends Activity implements OnClickListener, OnItemClickListener
|
public class AddAliasActivity extends Activity implements OnClickListener, OnItemClickListener, TextWatcher
|
||||||
{
|
{
|
||||||
private EditText aliasInput;
|
private EditText aliasInput;
|
||||||
private ArrayAdapter<String> adapter;
|
private ArrayAdapter<String> adapter;
|
||||||
private ArrayList<String> aliases;
|
private ArrayList<String> aliases;
|
||||||
|
private Button addButton;
|
||||||
private Button okButton;
|
private Button okButton;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -36,6 +39,7 @@ public class AddAliasActivity extends Activity implements OnClickListener, OnIte
|
|||||||
setContentView(R.layout.aliasadd);
|
setContentView(R.layout.aliasadd);
|
||||||
|
|
||||||
aliasInput = (EditText) findViewById(R.id.alias);
|
aliasInput = (EditText) findViewById(R.id.alias);
|
||||||
|
aliasInput.addTextChangedListener(this);
|
||||||
|
|
||||||
adapter = new ArrayAdapter<String>(this, R.layout.aliasitem);
|
adapter = new ArrayAdapter<String>(this, R.layout.aliasitem);
|
||||||
|
|
||||||
@ -43,7 +47,8 @@ public class AddAliasActivity extends Activity implements OnClickListener, OnIte
|
|||||||
list.setAdapter(adapter);
|
list.setAdapter(adapter);
|
||||||
list.setOnItemClickListener(this);
|
list.setOnItemClickListener(this);
|
||||||
|
|
||||||
((Button) findViewById(R.id.add)).setOnClickListener(this);
|
addButton = (Button) findViewById(R.id.add);
|
||||||
|
addButton.setOnClickListener(this);
|
||||||
((Button) findViewById(R.id.cancel)).setOnClickListener(this);
|
((Button) findViewById(R.id.cancel)).setOnClickListener(this);
|
||||||
|
|
||||||
okButton = (Button) findViewById(R.id.ok);
|
okButton = (Button) findViewById(R.id.ok);
|
||||||
@ -109,4 +114,16 @@ public class AddAliasActivity extends Activity implements OnClickListener, OnIte
|
|||||||
AlertDialog alert = builder.create();
|
AlertDialog alert = builder.create();
|
||||||
alert.show();
|
alert.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void afterTextChanged(Editable s) {
|
||||||
|
// Do nothing.
|
||||||
|
}
|
||||||
|
|
||||||
|
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||||
|
// Do nothing.
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||||
|
addButton.setEnabled(aliasInput.getText().length() > 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user