I have an activity with a custom view which extends EditText in it. Usually when someone longclicks an EditView a menu pops up asking the user to choose input method.
I have overridden the onLongClick to make this menu NOT appear, since
I use my own methods of input. However, i want a ListActivity to start when user longclicks the EditText (or rather again my view which extends EditText). But it seems a view cannot fire intents, only activities, am i right?
Fine, so i try to capture the longclick from the activity that spawned my EditText-like view. But inside my EditText-like view i already consume the longclick, either in the overridden onLongClick() by setting it true to avoid the “Please choose input method” menu to appear, or if returning false, then that very menu appears and consumes my longclick. In neither of the cases the intent fires…
In short:
A user longclicks an EditText, and i want a custom ListActivity to start. How do i accomplish this?
EDIT:
So i found startActivity in the Context object. But i will have the user pick an item from a list. That item would then appear in the EditText, so i thought i had to use startActivityForResult, which incidentally does not appear in the Context object 🙁
EDIT 2:
How do i get a result back from an activity started with startActivity?
You don’t need an Activity to start another Activity, but a Context object.
You got two options here. You can either pass an context into you custom view by using a custom constructor or a setter method. Or the OnLongClickListener has to be implemented in the Activity and set to the custom EditText from there.