我有一个我想要实现的场景,我不知道该怎么做:我想要的是当用户点击FAB窗口时出现一个窗口(从右到左有动画)选择的产品。我想几个解决方案,比如在我现有的片段上添加(不替换)片段(片段包含产品列表):
我在构造函数中获取上下文:
public ProductListAdapter(Context context, List<ProductPojo> productPojoList) {
inflater = LayoutInflater.from(context);
this.context = context;
this.productPojoList = productPojoList;
sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
try {
activity = (AppCompatActivity) context;
}catch (ClassCastException e){
Utils.myLogMsgs("can't get the frag manager with this");
}
}
而且在我的onBindViewHolder中我管理了click事件:
productHolder.fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
ProductDetailsFragment productDetailsFragment = new ProductDetailsFragment();
FragmentManager fragmentManager = activity.getSupportFragmentManager();
FragmentTransaction transaction = fragmentManager.beginTransaction();
transaction.setCustomAnimations(R.anim.product_animation_enter, R.anim.product_animation_exit);
transaction.add(R.id.item_detail_container, productDetailsFragment);
transaction.commit();
}
});
不幸的是它不起作用,当我点击工厂时没有任何反应!! 我一直在考虑实现导航抽屉来实现这种行为,但我不知道它是否是一种解决方案?!
当我按下fab时,这是我的logcat:
09-01 13:29:12.332 14826-14826/com.hermesit.bsproject I/Choreographer: Skipped 50 frames! The application may be doing too much work on its main thread.
09-01 13:29:13.072 14826-14826/com.hermesit.bsproject D/dalvikvm: GC_FOR_ALLOC freed 1354K, 20% free 7623K/9460K, paused 37ms, total 38ms
09-01 13:29:13.772 14826-14826/com.hermesit.bsproject I/Choreographer: Skipped 35 frames! The application may be doing too much work on its main thread.
09-01 13:29:24.212 394-452/system_process E/SoundPool: error loading /system/media/audio/ui/Effect_Tick.ogg
09-01 13:29:24.212 394-452/system_process W/AudioService: Soundpool could not load file: /system/media/audio/ui/Effect_Tick.ogg
09-01 13:29:24.222 394-452/system_process E/SoundPool: error loading /system/media/audio/ui/Effect_Tick.ogg
09-01 13:29:24.222 394-452/system_process W/AudioService: Soundpool could not load file: /system/media/audio/ui/Effect_Tick.ogg
09-01 13:29:24.222 394-452/system_process E/SoundPool: error loading /system/media/audio/ui/Effect_Tick.ogg
09-01 13:29:24.222 394-452/system_process W/AudioService: Soundpool could not load file: /system/media/audio/ui/Effect_Tick.ogg
09-01 13:29:24.222 394-452/system_process E/SoundPool: error loading /system/media/audio/ui/Effect_Tick.ogg
09-01 13:29:24.222 394-452/system_process W/AudioService: Soundpool could not load file: /system/media/audio/ui/Effect_Tick.ogg
09-01 13:29:24.222 394-452/system_process E/SoundPool: error loading /system/media/audio/ui/Effect_Tick.ogg
09-01 13:29:24.222 394-452/system_process W/AudioService: Soundpool could not load file: /system/media/audio/ui/Effect_Tick.ogg
09-01 13:29:24.222 394-452/system_process E/SoundPool: error loading /system/media/audio/ui/KeypressStandard.ogg
09-01 13:29:24.222 394-452/system_process W/AudioService: Soundpool could not load file: /system/media/audio/ui/KeypressStandard.ogg
09-01 13:29:24.222 394-452/system_process E/SoundPool: error loading /system/media/audio/ui/KeypressSpacebar.ogg
09-01 13:29:24.222 394-452/system_process W/AudioService: Soundpool could not load file: /system/media/audio/ui/KeypressSpacebar.ogg
09-01 13:29:24.222 394-452/system_process E/SoundPool: error loading /system/media/audio/ui/KeypressDelete.ogg
09-01 13:29:24.222 394-452/system_process W/AudioService: Soundpool could not load file: /system/media/audio/ui/KeypressDelete.ogg
09-01 13:29:24.222 394-452/system_process E/SoundPool: error loading /system/media/audio/ui/KeypressReturn.ogg
09-01 13:29:24.222 394-452/system_process W/AudioService: Soundpool could not load file: /system/media/audio/ui/KeypressReturn.ogg
09-01 13:29:24.222 394-452/system_process E/SoundPool: error loading /system/media/audio/ui/KeypressInvalid.ogg
09-01 13:29:24.222 394-452/system_process W/AudioService: Soundpool could not load file: /system/media/audio/ui/KeypressInvalid.ogg
09-01 13:29:24.222 394-452/system_process W/AudioService: onLoadSoundEffects(), Error -1 while loading samples
09-01 13:32:30.922 394-445/system_process D/MobileDataStateTracker: default: setPolicyDataEnable(enabled=true)
09-01 13:33:33.732 394-445/system_process D/ConnectivityService: Sampling interval elapsed, updating statistics ..
09-01 13:33:33.812 394-445/system_process D/ConnectivityService: Done.
09-01 13:33:33.812 394-445/system_process D/ConnectivityService: Setting timer for 720seconds
我拥有的是: find image here
我想要的是这个: find image here
PS:我的目标设备是在Android 4.4 kikat api 19上运行的7“或10”平板电脑。