-2
我創建了CustomListView。現在我想顯示'ShowCaseView',當我得到我的列表視圖是空的。它可能與否。當我的列表視圖爲空時,如何顯示ShowCaseView
我創建了CustomListView。現在我想顯示'ShowCaseView',當我得到我的列表視圖是空的。它可能與否。當我的列表視圖爲空時,如何顯示ShowCaseView
也許之前運行初始化或檢查的大小= 0
如果你的目標是創建一個ShowCaseView沒有目標,因爲你的列表視圖是空的,你可以使用!;
ShowcaseView.Builder showCaseViewBuild = new ShowcaseView.Builder(mActivity)
.setTarget(Target.NONE)
.[your_other_configuration_stuff_here];
,然後如果你試圖觸發此當列表視圖是空的,你可以設置更改到ListView層次的監聽器等;
ListView lv = new ListView(mActivity);
//[your ListView setup code here... then the listener below]
lv.setOnHierarchyChangeListener(new ViewGroup.OnHierarchyChangeListener() {
@Override
public void onChildViewAdded(View parent, View child) {
}
@Override
public void onChildViewRemoved(View parent, View child) {
// trigger your ShowCaseView here when no children are left
// TODO
}
});
這是可能的,檢查是否列表尺寸是0,並且進行到顯示showcaseview –
檢查是否'陣列== NULL || array.isEmpty()'然後顯示ShowCaseView否則顯示列表視圖。 – user392117
我該如何處理notifyDataSetChanged()方法。因爲在我的情況下,它會自動刷新列表視圖? – Nik