Currently I am making an app that has an EditText on the action bar. I found out how to put a custom view on an actionbar from the following link: How to set a custom view in actionbar in android?. I used the getSupportActionBar to load an EditText onto the action bar.
getSupportActionBar.setCustomView(R.layout.actionbar_view);
It loads an xml file called actionbar_view.xml. The code for that xml file follows below.
<?xml version="1.0" encoding="utf-8"?>
<EditText xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/searchfield"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:hint="Search for some app" >
</EditText>
The problem is that unlike all normal EditTexts placed on the area below an actionbar the edit text on the actionbar is not automatically selected. Is there a way to make this Edit Text on the action bar automatically selected?
By the way, I did take a look at the following link, How to focus and show soft keyboard when a EditText is shown in action bar? Unfortunately I tried to understand the solution and apply to my code but the edit text was still not automatically selected. I am still pretty new to stack overflow, so in case I am not providing enough information/code to solve my problem please tell me in the comments. Thank you!