我试图在同一活动中实现导航抽屉和视图寻呼机.导航抽屉工作正常,但视图寻呼机不工作,我也在导航抽屉打开时右侧滑动指针(空指针在android.支持.v4.小部件.GrawerLayout.isContentView(DrawerLayout.java:840).我我附加了主要的xml布局和代码.
<android.support.v4.view.ViewPager
android:id="@+id/viewpager"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
</android.support.v4.view.ViewPager>
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ListView
android:id="@+id/left_drawer"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="#111"
android:choiceMode="singleChoice"
android:divider="@android:color/transparent"
android:dividerHeight="0dp" />
</android.support.v4.widget.DrawerLayout>
Run Code Online (Sandbox Code Playgroud)
活动类如下
public class MainActivity extends Activity {
private DrawerLayout mDrawerLayout;
private ListView mDrawerList;
private ActionBarDrawerToggle mDrawerToggle;
private CharSequence mDrawerTitle;
private CharSequence mTitle;
private String[] mPlanetTitles;
private MainActivity mContext;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mContext = this;
ViewPager vp = (ViewPager) findViewById(R.id.viewpager);
CustomPagerAdapter adapter = new CustomPagerAdapter(mContext);
vp.setAdapter(adapter);
vp.setPageTransformer(false, new ViewPager.PageTransformer() {
@Override
public …Run Code Online (Sandbox Code Playgroud) 我在我的应用程序中遵循MVP架构.我的HomeActivity包含一个带有列表图标的滑动面板,其中包含选择器,选择滑动面板项目时图标状态已更改,我没有使用任何列表选择器.
我保留了一个模型类NavItemData,用于填充导航抽屉,并使用扩展StateListDrawable 的类SlidingPanelItemSelector为滑动面板图标生成适当的选择器.
在MVP架构中,我们有一个演示者类,它与模型通信并生成视图的输入.在我的情况下,如果我使用演示者获取滑动面板的数据我正在调用使用Android上下文的演示者的类是一个很好的方法,或者我们有任何替代解决方案,严格遵循MVP架构?
目前我正在使用ViewBinderUtils类并将其直接注入活动类并获取Sliding Panel的数据列表.它是否遵循Mvp Architcture?
SlidingPanelItemSelector.class
public class SlidingPanelItemSelector extends StateListDrawable {
private Context mContext;
public SlidingPanelItemSelector(Context mContext){
this.mContext = mContext;
}
public StateListDrawable getHomeSelector(){
StateListDrawable stateListDrawable = new StateListDrawable();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
stateListDrawable.addState(new int[]{android.R.attr.state_pressed},
mContext.getDrawable(R.drawable.ic_nav_home_active));
stateListDrawable.addState(new int[]{},mContext.getDrawable(R.drawable.ic_nav_home));
}else{
stateListDrawable.addState(new int[]{android.R.attr.state_pressed},
mContext.getResources().getDrawable(R.drawable.ic_nav_home_active));
stateListDrawable.addState(new int[]{},mContext.getResources().getDrawable(R.drawable.ic_nav_home));
}
return stateListDrawable;
}
}
Run Code Online (Sandbox Code Playgroud)
ViewBinderUtils.class
public class ViewDataBinderUtils {
Context mContext;
@Inject
public ViewDataBinderUtils(@ActivityContext Context mContext) {
this.mContext = mContext;
}
public …Run Code Online (Sandbox Code Playgroud) mvp android android-layout android-selector navigation-drawer
我正在从存储在我的SD卡中的视频创建缩略图,在网格视图中显示缩略图及其名称.在网格视图的项目选定事件上弹出一个对话框,询问x,y,右,底部位置,然后将其粘贴到主活动.我收到了视频文件,并试图使用媒体商店创建缩略图也检索缩略图作为位图,但位图为空.在网格视图中显示视频名称,我可以选择相应的缩略图,并且可以给出位置,也可以将缩略图设置为主要活动.问题是位图为空并且位图图像未显示(文本视频名称显示).有什么问题 ?我弄清楚了吗?Plz帮帮我?我的代码如下.提前致谢.
if (f.isFile()) {
if (fName.endsWith(".mpg")
|| fName.endsWith(".mov")
|| fName.endsWith(".wmv")
|| fName.endsWith(".rm")
|| fName.endsWith(".mp4")) {
tv.setText(fName);
path = f.getAbsolutePath();
System.out.println("Video file path=>"+path);
thumb = ThumbnailUtils.createVideoThumbnail(f.getAbsolutePath(),MediaStore.Video.Thumbnails.MICRO_KIND);
if(thumb==null)
{
/**Every time it printing null**/
System.out.println("Thumb is null");
}
iv.setImageBitmap(thumb);
Run Code Online (Sandbox Code Playgroud)