7月 162012
1. App crashes when it starts, because I make a error to set TextView.textcolor to a String resource Value, it should be a drawable resource value
1 2 3 4 5 6 7 8 |
<?xml version="1.0" encoding="utf-8"?> <resources> <string name="mainbtnlogin">Login</string> <drawable name="general_back_color">#FFFFFF</drawable> //this is right to assign to a color type variable <string name="general_text_color">#000000</string> //this is wrong to assign to a color type variable <drawable name="general_linkable_color">#0000FF</drawable> <string name="value_zero">0</string> </resources> |
2. I wrote a function which used Context of the activity. But when I finished coding, eclipse gave an error message. After a about 1 hour research, I finally found I wrote the function in the subclass of the activity. After moving the function to the main class, it works.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
package em8.admin; //import a lot of packages public class Em8MainActivity extends Activity { /** Called when the activity is first created. */ @SuppressLint({ "ParserError", "NewApi" }) @Override public void onCreate(Bundle savedInstanceState) { setContentView(R.layout.main); ... } public class ShowStatisticsTask extends AsyncTask<String, integer, Long>{ LogResItem lrItem = null; SharedPreferences prefs = getSharedPreferences(ConstData.Settings_file_name, MODE_PRIVATE); @Override protected Long doInBackground(String... params) { } protected void onPostExecute(Long result) { } //It is difficult to find, right? public void showNotification(int icon,String tickertext,String title,String content){ Notification notification=new Notification(icon,tickertext,System.currentTimeMillis()); notification.defaults=Notification.DEFAULT_ALL; PendingIntent pt=PendingIntent.getActivity(this, 0, getIntent(), 0); notification.setLatestEventInfo(this,title,content,pt); notifyMgr.notify(notification_id, notification); } } } |
3. (be continued…)