I have up to 4 edit views (amount changes dynamically) in a linearLayout
how can I set the cursor to appear in none of them at the beginning?
This activity ignores onConfigurationChange and i want to de-select previous user choice.
meaning in the onCreate i want to de-select all of them.
I have tried this:
findViewById(R.id.editText1).setSelected(false);
for each of them, but the cursor stayed.
I want the curser appear again when the user clicks but then disappear again onCreate (after screen rotation till another user click)
findViewById(R.id.editText1).setCursorVisible(false);
this will make the caret not visible, even if the edit text is enabled, selected and being edited
Try:
android:windowSoftInputMode="stateHidden"
in your manifest for each activity in which you do not want focus for the edit text at the start.
Related
I have a button in an activity, on clicking that button, I direct the user to a search activity with a search view in the toolbar..
I'm using android.support.v7.widget.SearchView, I managed to expand it automatically using searchView.setIconifiedByDefault(false) in onCreateOptionsMenu..
I also open the keypad automatically in activity onCreate, yet I still have to click in the searchView to start typing there, I want the cursor to be set there automatically..
any help?
call setIconifiedByDefault(false) when the searchview is intialized.
Sets the default or resting state of the search field. If true, a single search icon is shown by default and expands to show the text field and other buttons when pressed. Also, if the default state is iconified, then it collapses to that state when the close button is pressed. Changes to this property will take effect immediately.
Try the below, it worked for me once.
searchView.setIconifiedByDefault(true);
searchView.setFocusable(true);
searchView.setIconified(false);
searchView.requestFocusFromTouch();
Update: If you are Using android.support.v7.widget.SearchView the behaviour is very different. clearFocus is needed if you don’t want the keyboard pop-up all the time.
Also in the searchview layout, use <requestFocus /> tag.
I'm building an Android app that syntax highlights source code files. Previously, I had performance issues with large files, so my editor is now a RecyclerView where each cell contains an EditText. While my app is performing great now, unfortunately the RecyclerView doesn't always behave like an EditText.
In particular, when I hold the EditText highlighting the word beneath my finger, and try to drag the slider past the number of lines in the EditText, I hit an impasse where I am unable to progress further:
(Sorry, wasn't able to scale the image down)
In the above image, I can't drag past the end of the highlighted region.
A similar problem happens when I:
Tap somewhere (without highlighting), and try to drag the slider down
Hold my finger, then select 'Select All'. Only what's in the current EditText is highlighted.
How do I make the RecyclerView act as if it's a single EditText? Thanks.
In my Android Project, whenever I go from First Activity to Second, I get an left arrow button followed by the some text in the action bar. That left arrow only comes when I set my First Activity as the hierarchical parent of the Second Activity.
I want to remove that back button and replace it with an icon. I have read other posts for the same question, and so I have already tried the following code in my onCreate() method.
getActionBar().setDisplayHomeAsUpEnabled(false);
But after reaching to the second activity, the app gets crashed.
Please help me out.
Use getSupportActionBar() bar:
getSupportActionBar().setDisplayHomeAsUpEnabled(false);
getSupportActionBar().setHomeButtonEnabled(false);
getSupportActionBar().setHomeAsUpIndicator(R.drawable.ic_yourindicator);
I've created a class called ClickableRow which highlights the row and changes the text color of all the TextViews inside of it, then returns the row to its initial settings after the user stops clicking or scrolls too far, but I feel like android probably already has a built in function for this.
The main thing that I want to accomplish is to change all the TextViews in the row so that they are white when a click happens, and return to their previous color after a click or a scroll happens. I am sort-of accomplishing this, but for now I just have it turning the TextViews text to black afterwards. This isn't always the correct color, so is there a way to highlight text on a click and put it back to its default after?
Thanks.
There's a handy property of all Views in android called the Tag (as you might know).
It means you can store whatever you want as data in a particular View.
So in your case, you will store the textview desired color in its TAG, so you can trivially know its state:
void setTextViewColor(TextView textView, int color) {
textView.setTag((Integer)color);
textView.setColor(color);
}
void restoreTextViewToItsDefaultColor(TextView textView) {
Integer myColor=(Integer)textView.getTag();
textView.setColor(myColor);
}
So given a TextView:
TextView myTextView=new TextView(context);
setTextViewColor (Color.RED); // sets to red AND stores red in the tag
later on, you manually change to your row color:
myTextView.setColor(Color.BLUE);
then to revert to the original you do
restoreTextViewToItsDefaultColor(myTextView);
If you manually change
hope it helps !
I have numerous edittexts inside a listview. I want to type in each of the edittexts one by one without having to scroll through the listview. How can I do that?
Use the android:nextFocusDown param to specify which field you'd like to get focus when the user hits the enter key.