Here is a java program to replace space with "%20" in a string. For example, the string "We Are Happy" will be changed to "We%20Are%20Happy".
Note that a space is a character while "%20" is a string.
//Replace Space With "%20" In A String
public class Solution {
public String replaceSpace(StringBuffer str) {
StringBuffer s = new StringBuffer();
for(int i=0;i<str.length();++i) {
if (str.charAt(i)==' ') {
s.append("%20");
} else {
s.append(str.charAt(i));
}
}
return s.toString();
}
}
Wednesday, August 17, 2016
Monday, August 8, 2016
Android Studio Project: Outside News
The previous projects I have made are mainly about logical thinking. Today, I share this project, Outside News to all of you, which is full of beautiful user interfaces. I'm sorry that it's only a demo without news recources and strong features. If you want to have a try, just do it!
Installation package
Project site
Is this project with the use of Viewpager, ListView, PopupWindow, PopupMenu and many other views more colorful? What's more, it uses SharedPreferences and SQLite database to store some data persistently. And it involves multithread programming and asynchronous message processing. The use of vector is also one of my harvests.
Installation package
Project site
Is this project with the use of Viewpager, ListView, PopupWindow, PopupMenu and many other views more colorful? What's more, it uses SharedPreferences and SQLite database to store some data persistently. And it involves multithread programming and asynchronous message processing. The use of vector is also one of my harvests.
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: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"
android:background="@null"
Subscribe to:
Posts (Atom)