關於android的警告問題

1.關於main.xml中使用ImageView引起Missing contentDescription attribute on image 的問題 

    在main.xml中關於ImageView控件的添加時,如果沒有加android:contentDescription="@string/app_name",便會引起Missing contentDescription attribute on image ,主要是因爲在main.xml中沒有使用TextView之類的文本控件,ADT會提示給像ImageView增加一個說明,這裏添加android:contentDescription="@string/app_name即可,其實加不加影響不大。只是在IDE中會顯示一個黃色下劃線,不美觀。

2.關於TextView.setText("")的CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.

    在此問題中,TextView無法正常刷新線程,我們可以使用

	Message msg = new Message();
	msg.what = n;
	theTimeHandler.sendMessage(msg);

	private static Handler theTimeHandler = new Handler(){
		public void handleMessage(Message msg){
			timeLabel.setText(String.valueOf(n));
			super.handleMessage(msg);
		}
	};

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章