紅色字體:錯誤點,產生bug時,控制檯打印的error;
藍色字體:錯誤的原因;
1。 sharedPreference.edit(); 保存數據後,及得 commit();否則數據不會提交保存
eg:
Editor editor = sharedPreference.edit();
editot.putString(key, value);
editor.commit();
2.用 service 或者 broadcastreceiver 激活 activity 組件時,用於 service 或者 broadcastreceiver 都不存在 存放activity 的任務棧,故,要 給 intent 設置 flags;
eg:
Intent activity = new Intent (context, LostProtectedActivity.class);
activity.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(activity);
setResultData(null);
3.自定義的dialog 使用後 記得 dismiss();
4.同樣都是Context,那麼MainActivity.this 和 MainActivity.getApplication () 的區別:
如果要在當前的 activity 顯示 其他的組件(如:dialog組件),在使用 MainActivity.this,讓資源在當前的 組件中顯示;
如果所要得到的資源在 Context,那麼要使用getApplication ()得到 app 的上下文資源對象
5.在使用ListActivity時
activity_atool_commonnum.xml{
<ExpandableListView
android:id="@+id/elv"
android:layout_width="match_parent"
android:layout_height="match_parent">
</ExpandableListView>
}
public class AtoolCommonNumActivity extends ListActivity {
private ExpandableListView el_commonnum_listdata;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_atool_commonnum);
el_commonnum_listdata = (ExpandableListView) this.findViewById(R.id.elv);
}
error:
Caused by: java.lang.RuntimeException: Your content must have a ListView whose id attribute is 'android.R.id.list'
原因:
If you use a ListActivity
the id
for
your ListView
in
your layout should be
@android:id/list, like in this example:
6.這樣的事情發生,讓程序員很痛苦啊。。。
cocos2d-android源代碼及jar包,如果你關聯源碼的時候,出現提示:“The
Jar of this class file belongs to container 'Android Dependencies' which does not allow modifications to source attachments on its entries”那是因爲你把包放在libs文件夾下面了,解決方案:新建一個lib文件夾,然後把jar包放在lib文件夾即可,放在libs下面就無法關聯了=_=
持續更新中 。。。。。。