I have created a Activity which extends FixedExpandableListActivity.
In my Activity, I am having EditText where in after entering some text, and doing a long press on the EditText, copy paste option is not appearing.
Doing multiple taps on the EditText, copy paste option pops up and disappear.
Issue is observed on 4.1.2.
Can some one please help out how to fix this issue.
My gremlin for this problem was a combination of windowSoftInputMode="adjustResize" and a View.OnLayoutChangeListener which was reparenting the EditText, for unrelated reasons. (Removing the EditText caused the copy/paste actions to disappear, sensibly enough.) Hard to track down.
Related
I have a button that creates an EditText, now I have a button that deletes the last element, but if I click it 2 times, I get an error because when I "spawn" an EditText I create a View:
code
vista = LayoutInflater.from(this).inflate(R.layout.edit, null);
When I go to delete it (so I delete 1 EditText) this view will be deleted too, but if I press the button once, I get error (don't remember which).
so i create an ArrayList that contains all the view spawned (every time i press the button for add them) and all do right, but when i have to remove EditText i remove Element by ArrayList but in app EditText will not be removed.
any suggestion?
I will give you the answer from what i have understood from your explanation. If I have not clear with what you needed. please do clarify so, that I can help you.
You are creating EditText dynamically and adding to the parent Layout.
parentView.addView(edittextObject);
Adding a edittext is working good. but, removing of edittext is not performing.
If this is your question.
Remove the selected edittext by clicking on delete button listener.
parentLayout.removeView((View) v.getParent());
This single line of code will remove edittext from parent layout.
I'm working on Espresso tests for Android and for one of my actions I want to search a list using a SearchView, select an item and then navigate back to the previous screen (by closing the searchview and then pressing the up button).
I've tried some things to access the up/collapse button of the SearchView to close it (that don't work):
onView(withContentDescription(R.string.abc_action_bar_up_description))
onView(withId(R.id.search_close_btn))
onView(withId(R.id.home))
onView(withId(R.id.homeAsUp))
onView(withId(R.id.collapseActionView))
Espresso.pressBack() (to just navigate back)
I'm hoping someone might know some way to access and close this button, because I have no idea.
Thanks in advance.
Apparantly I had to press the back button twice to navigate out of it, so if anyone would like to know, you need to use Espresso.pressBack(); twice to get out of the search menu.
The correct id is R.id.search_close_btn
onView(withId(R.id.search_close_btn)).perform(click())
I was with the same problem of accessing this up/collapse button and by reading the hierarchy of components I found out that this button has the content description of 'Collapse'. So using the following solved the problem for me:
onView(withContentDescription(androidx.appcompat.R.string.abc_toolbar_collapse_description)).perform(click())
I'm having a problem with the softkeyboard not showing when i click on a EditText.
The activity goes like this.
1. Activity starts
2. Dialog box opens with a custom keyboard
3. And then I try to click on an empty EditText field to put in data, but nothing happens. The field get focus, but keyboard doesn't show up.
I haven't done anything funky with disabling keyboard..
Anyone know whats going on?
If you're using AVD manager add a hardware property Keyboard support and set it to false.
That should disable the shown keyboard, and show the virtual one.
I have an EditText that recieves input and prints in on the screen. I need to find a way wherein after click submit or enter, the phone will focus on the EditText
I tried
txtJoke.setFocusable(true);
txtJoke.setFocusableInTouchMode(true);
txtJoke.requestFocus();
and it doesn't work..
requestfocus works during onCreate..
I'm thinking of manually triggering a click an edittext..
You can use ...
Button newButton.setOnFocusChangeListener(new View.onFocusChangeListener) {....}
to specify where will be the focus go next.
Whenever I have an EditText field in my android application, it is highlighted with the blinking cursor for input as soon as the activity is started (though the keyboard doesn't pop up). How can I disable this?
EditText and ListView are focusable in touch mode so when you launch your application by tapping on its icon (putting you into touch mode) the first one in your application will likely get focus. Had you entered your application by using the D-pad (moving you out of touch mode) the first Button, Spinner, EditText, or ListView would get the focus since they are all focusable.
I wouldn't get too hung up on the a View being in focus when your application starts but if you really can't stand the default way of handling focus, you could try giving focus to a TextView since it doesn't look different when it is in focus. Keep in mind that it isn't normally focusable in touch mode so you will need to enable it prior to requesting focus. Since this is a bit hacky, others (myself included) will caution you against going down this route and likely encourage you to accept the normal behavior.
View tv = findViewById(R.id.MyTextView);
tv.setFocusableInTouchMode(true);
tv.requestFocus();
PS: You may also want to check out this other SO question as it is nearly identical to yours.
You could call setFocusable(false) to avoid this. But if it should become focus later then maybe you have to call setFocusable(true) again later.