I was following a toolbar tutorial and when I tried to add an edit text below it and then ran it on my physical device, I was unable to enter any text into it. I don't know what I did wrong. I applied a custom text color to the edit text in the apptheme, but I doubt it that the problem is because of this.
This is my xml code:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<include
android:id="@+id/toolbar"
layout="@layout/tool_bar"/>
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/editText"
android:layout_below="@+id/toolbar"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:textSize="30sp"
android:hint="enter text"/>
and this is what I have in my style.xml file:
sources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/ColorPrimary</item>
<item name="colorPrimaryDark">@color/ColorPrimaryDark</item>
<item name="android:editTextStyle">@style/CustomEditText</item>
</style>
<style name="CustomEditText">
<item name="android:textColor">#ab42</item>
</style>
This is my main activity:
public class MainActivity extends AppCompatActivity {
private Toolbar mToolbar;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mToolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(mToolbar);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_main,menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
if(id == R.id.action_search){
Toast.makeText(this,"SEARCH",Toast.LENGTH_LONG).show();
}else if(id == R.id.action_user){
Toast.makeText(this,"User",Toast.LENGTH_LONG).show();
}else{
Toast.makeText(this,"Overflow",Toast.LENGTH_LONG).show();
}
return super.onOptionsItemSelected(item);
}
I found the problem, myself. I forgot to inherit from some of the theme's base edit texts like that: