Sunday, August 7, 2016

Android Learning Note: To Set The Color Of Cursor The Same As Text Color In An EditText

To set the color of cursor the same as text color in an EditText, just add a sentence in the layout file like this:

 android:textCursorDrawable="@null"

"@null" here means the color of cursor is the same with the text. It's said that you can change it as you like to set the color arbitrarily. You may have a try.

Android Learning Note: To Delete The Default Bottom Line Of EditText

To delete the default bottom line of EditText, just add the following sentence in the layout file, of course, between "<EditText" and "/>".

android:background="@null"

Friday, August 5, 2016

Android Learning Note: Never Set 2 Different Layout To 1 Activity

This is the original post of mine, which is wrong in fact.



Just add the following codes behind "super.onCreate(savedInstanceState);" sentence in the onCreate(Bundle savedInstanceState) methed of the main Activity.


//Entering Splash Screen. Here I use the layout file welcome.xml
setContentView(R.layout.welcome);

// Creating a Handler object and operate it like this. You may set another waiting time
new Handler() {
    @Override    public void handleMessage(Message msg) {
        setContentView(R.layout.activity_main);
    }
}.sendEmptyMessageDelayed(1,2000);

After short enjoyness, I got into trouble caused by the codes below. Crap say no more, I used the methed setContentView() twice in the codes below, which caused serious NullPointerException in the following codes.
Maybe this is a stupid mistake for many of you, I thgink it valuable for me, for I have debuged the program and resulted others to make sense of it. And I'm impressed on this error, believing that I'll never make this kind of mistake.

Never Set 2 Different Layout To 1 Activity.