Search in sources :

Example 6 with OnEditorActionListener

use of android.widget.TextView.OnEditorActionListener in project androidannotations by androidannotations.

the class EditorActionsActivityTest method testValueReturnedFromNonVoidEditorActionMethod.

@Test
public void testValueReturnedFromNonVoidEditorActionMethod() {
    TextView editText = (TextView) activity.findViewById(R.id.textView2);
    OnEditorActionListener listener = getOnEditorActionListener(editText);
    assertThat(listener.onEditorAction(editText, 0, null)).isFalse();
}
Also used : TextView(android.widget.TextView) OnEditorActionListener(android.widget.TextView.OnEditorActionListener) Test(org.junit.Test)

Example 7 with OnEditorActionListener

use of android.widget.TextView.OnEditorActionListener in project androidannotations by androidannotations.

the class EditorActionsActivityTest method testTrueReturnedFromVoidEditorActionMethod.

@Test
public void testTrueReturnedFromVoidEditorActionMethod() {
    EditText editText = (EditText) activity.findViewById(R.id.editText3);
    OnEditorActionListener listener = getOnEditorActionListener(editText);
    assertThat(listener.onEditorAction(editText, 0, null)).isTrue();
}
Also used : EditText(android.widget.EditText) OnEditorActionListener(android.widget.TextView.OnEditorActionListener) Test(org.junit.Test)

Example 8 with OnEditorActionListener

use of android.widget.TextView.OnEditorActionListener in project android-delicious by lexs.

the class AddBookmarkActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_add_bookmark);
    setTitle(R.string.activity_add_bookmark_title);
    // Enable up button
    getActionBar().setHomeButtonEnabled(true);
    errorDrawable = DeliciousApplication.getErrorDrawable();
    titleFetcher = new TitleFetcher(this);
    receiver = new DetachableResultReceiver(new Handler());
    urlView = (EditText) findViewById(R.id.url);
    titleView = (EditText) findViewById(R.id.title);
    notesView = (EditText) findViewById(R.id.notes);
    tagsView = (MultiAutoCompleteTextView) findViewById(R.id.tags);
    privateView = (CheckBox) findViewById(R.id.mark_private);
    // TODO: Implement tag suggestion
    /*ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
                android.R.layout.simple_spinner_dropdown_item, TAGS);
        tagsView.setAdapter(adapter);
        tagsView.setTokenizer(new MultiAutoCompleteTextView.CommaTokenizer());*/
    // Enable user to press enter when done
    tagsView.setOnEditorActionListener(new OnEditorActionListener() {

        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_DONE) {
                saveBookmark();
                return true;
            } else {
                return false;
            }
        }
    });
    Intent intent = getIntent();
    if (Intent.ACTION_SEND.equals(intent.getAction())) {
        String url = intent.getStringExtra(Intent.EXTRA_TEXT);
        String title = intent.getStringExtra(Intent.EXTRA_SUBJECT);
        urlView.setText(url);
        titleView.setText(title);
        // Check were focus should go
        if (TextUtils.isEmpty(url)) {
            urlView.requestFocus();
        } else if (TextUtils.isEmpty(title)) {
            titleView.requestFocus();
        } else {
            // Focus tags because it can't be prefilled
            tagsView.requestFocus();
        }
    }
    // Fetch title if necessary
    titleFetcher.maybeFetchTitle();
}
Also used : KeyEvent(android.view.KeyEvent) Handler(android.os.Handler) OnEditorActionListener(android.widget.TextView.OnEditorActionListener) MultiAutoCompleteTextView(android.widget.MultiAutoCompleteTextView) TextView(android.widget.TextView) Intent(android.content.Intent) DetachableResultReceiver(se.alexanderblom.delicious.util.DetachableResultReceiver) TitleFetcher(se.alexanderblom.delicious.helpers.TitleFetcher)

Example 9 with OnEditorActionListener

use of android.widget.TextView.OnEditorActionListener in project roboguice by roboguice.

the class AstroboyMasterConsole method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    // @Inject, @InjectResource, and @InjectExtra injection happens during super.onCreate()
    super.onCreate(savedInstanceState);
    sayText.setOnEditorActionListener(new OnEditorActionListener() {

        public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
            // Have the remoteControl tell Astroboy to say something
            remoteControl.say(textView.getText().toString());
            textView.setText(null);
            return true;
        }
    });
    brushTeethButton.setOnClickListener(new OnClickListener() {

        public void onClick(View view) {
            remoteControl.brushTeeth();
        }
    });
    selfDestructButton.setOnClickListener(new OnClickListener() {

        public void onClick(View view) {
            // Self destruct the remoteControl
            vibrator.vibrate(2000);
            remoteControl.selfDestruct();
        }
    });
    // Fighting the forces of evil deserves its own activity
    fightEvilButton.setOnClickListener(new OnClickListener() {

        public void onClick(View view) {
            startActivity(new Intent(AstroboyMasterConsole.this, FightForcesOfEvilActivity.class));
        }
    });
}
Also used : KeyEvent(android.view.KeyEvent) OnClickListener(android.view.View.OnClickListener) OnEditorActionListener(android.widget.TextView.OnEditorActionListener) TextView(android.widget.TextView) Intent(android.content.Intent) ContentView(roboguice.inject.ContentView) InjectView(roboguice.inject.InjectView) TextView(android.widget.TextView) View(android.view.View)

Example 10 with OnEditorActionListener

use of android.widget.TextView.OnEditorActionListener in project mobile-android by photo.

the class TagsFragment method init.

public void init(View v) {
    final EditText search = (EditText) v.findViewById(R.id.edit_search);
    search.setOnEditorActionListener(new OnEditorActionListener() {

        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (event != null) {
                switch(event.getKeyCode()) {
                    case KeyEvent.KEYCODE_ENTER:
                        CommonUtils.debug(TAG, "Key code enter");
                        if (KeyEvent.ACTION_DOWN == event.getAction()) {
                            CommonUtils.debug(TAG, "Opening gallery");
                            search.post(new Runnable() {

                                @Override
                                public void run() {
                                    galleryOpenControl.openGallery(search.getText().toString().trim(), null);
                                }
                            });
                            return true;
                        }
                        break;
                }
            }
            return false;
        }
    });
    Button filterBtn = (Button) v.findViewById(R.id.filterBtn);
    filterBtn.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            TrackerUtils.trackButtonClickEvent("filterBtn", TagsFragment.this);
            galleryOpenControl.openGallery(mAdapter.getSelectedTags(), null);
        }
    });
    refresh(v);
}
Also used : EditText(android.widget.EditText) KeyEvent(android.view.KeyEvent) Button(android.widget.Button) OnClickListener(android.view.View.OnClickListener) OnEditorActionListener(android.widget.TextView.OnEditorActionListener) TextView(android.widget.TextView) TextView(android.widget.TextView) View(android.view.View) ListView(android.widget.ListView)

Aggregations

OnEditorActionListener (android.widget.TextView.OnEditorActionListener)37 KeyEvent (android.view.KeyEvent)32 TextView (android.widget.TextView)32 View (android.view.View)28 DialogInterface (android.content.DialogInterface)13 LayoutInflater (android.view.LayoutInflater)13 EditText (android.widget.EditText)13 OnClickListener (android.view.View.OnClickListener)12 AlertDialog (android.app.AlertDialog)11 Context (android.content.Context)11 OnClickListener (android.content.DialogInterface.OnClickListener)11 Intent (android.content.Intent)9 Test (org.junit.Test)6 ContentResolver (android.content.ContentResolver)5 Button (android.widget.Button)4 InjectView (roboguice.inject.InjectView)4 Handler (android.os.Handler)3 AlertDialog (android.support.v7.app.AlertDialog)3 InputMethodManager (android.view.inputmethod.InputMethodManager)3 AutoCompleteTextView (android.widget.AutoCompleteTextView)3