我有一个片段,我在其中使用recyclerview适配器在recyclerview中使用recyclerview和设置数据.
现在,我在适配器的列表项中点击了一个按钮,我需要在android中检查android中的新权限模型的READ_EXTERNAL_STORAGE权限.
我已在此适配器的片段中创建了一个新函数,以检查是否授予了权限,如果尚未授予权限,则请求权限.
我已经通过MyFragment.this作为适配器中的参数,并在按钮单击适配器中调用片段的方法.
我使用下面的代码在片段中调用requestPermission.
if(ContextCompat.checkSelfPermission(mContext, Manifest.permission.READ_EXTERNAL_STORAGE)
!= PackageManager.PERMISSION_GRANTED)){
requestPermissions(new String[]{Manifest.permission.READ_EXTERNAL_STORAGE},
ConstantVariables.READ_EXTERNAL_STORAGE);
}
Run Code Online (Sandbox Code Playgroud)
我onRequestPermissionsResult使用下面的代码覆盖了片段中的方法:
@Override
public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) {
switch (requestCode) {
case ConstantVariables.READ_EXTERNAL_STORAGE:
// If request is cancelled, the result arrays are empty.
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
// permission was granted, proceed to the normal flow.
startImageUploading();
} else {}
Run Code Online (Sandbox Code Playgroud)
但它没有被调用,而是调用了这个Activity的onRequestPermissionsResult方法.
我已经在片段的父活动中定义了相同的onRequestPermissionsResult方法,并且它被调用.
我无法删除活动的onRequestPermissionsResult方法,但是当我请求片段的权限时,我想调用片段的onRequestPermissionsResult方法.我怎样才能做到这一点?我在这里做错了什么,如果有人在这里有想法,请帮助我.
我正在使用带有viewpager的CollapsingBarLayout,并且viewpager的片段具有listview,gridview.
这是我的代码:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.bigsteptech.seandroidnativeapp.classes.modules.common.ViewGroupEvent">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:fitsSystemWindows="true">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:expandedTitleMarginEnd="64dp"
app:expandedTitleMarginStart="48dp"
app:expandedTitleTextAppearance="@style/TransparentText">
<FrameLayout
android:id="@+id/carouselLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_collapseMode="parallax">
<ImageView
android:id="@+id/coverImage"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"/>
<LinearLayout
android:layout_width="match_parent"
android:gravity="bottom"
android:orientation="vertical"
android:layout_gravity="bottom"
android:padding="@dimen/profile_image_margin"
android:background="@drawable/gradient_bg"
android:layout_height="wrap_content">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/profile_image_margin"
android:textSize="@dimen/text_size_xlarge"
android:textStyle="bold"
android:textColor="@color/white"
android:id="@+id/content_title"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_marginLeft="@dimen/profile_image_margin"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:textColor="@color/white"
android:textSize="@dimen/text_size_medium"
android:id="@+id/category_title"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:layout_toRightOf="@+id/category_title"
android:layout_marginLeft="@dimen/profile_image_margin"
android:textColor="@color/white"
android:textSize="@dimen/text_size_medium"
android:id="@+id/memberCount"/>
</RelativeLayout>
</LinearLayout>
</FrameLayout>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar" …Run Code Online (Sandbox Code Playgroud) 我的布局中有一个EditText字段.我想在用户停止输入该edittext字段时执行操作.我已经实现了TextWatcher并使用了它的功能
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) { }
@Override
public void onTextChanged(CharSequence text, int start, int lengthBefore, int lengthAfter) { }
@Override
public void afterTextChanged(Editable editable) {
}
Run Code Online (Sandbox Code Playgroud)
功能onTextChanged和afterTextChanged得到的只是输入任何字符后调用,但我希望用户在该领域的EditText完成键入后,就像Facebook并在它的"入住"页面进行操作.
我该如何实现呢?
我有一个RecyclerView,每个项目RecyclerView都有ImageView.我正在ImageView使用Glide加载图像,当我向下滚动RecyclerView它加载图像时这很好,但是当我再次向上srcoll RecyclerView它再次加载那些已经加载的图像.我不想再次加载已经加载的图像.
我使用以下代码使用Glide加载图像
Glide.with(mActivity)
.load(img.getmGridViewImageUrl())
.into(imageHolder.imageView);
Run Code Online (Sandbox Code Playgroud) 我在嵌套的Scrollview中使用带有NestedScrollView和Viewpager的Collapsing ToolBar Layout.
我有3个标签,这些标签有3个片段.这些片段使用RecyclerView来设置数据.
现在使用nestedScrollView和viewpager,当我滚动RecyclerView内容时,折叠效果不适用于此.
我还需要放置NestedScrollView,因为我需要在Tabs上面显示一些信息.
这是我的代码:
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:fitsSystemWindows="true">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:expandedTitleMarginEnd="64dp"
app:expandedTitleMarginStart="48dp"
app:expandedTitleTextAppearance="@style/TransparentText">
<FrameLayout
android:id="@+id/carouselLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
android:fitsSystemWindows="true"
app:layout_collapseMode="parallax">
<ImageView
android:id="@+id/coverImage"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/example"
android:scaleType="centerCrop"/>
<LinearLayout
android:layout_width="match_parent"
android:gravity="bottom"
android:orientation="vertical"
android:layout_gravity="bottom"
android:padding="@dimen/profile_image_margin"
android:background="@drawable/gradient_bg"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:layout_height="wrap_content">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/profile_image_margin"
android:textSize="@dimen/text_size_xlarge"
android:textStyle="bold"
android:textColor="@color/white"
android:text="Title"
android:id="@+id/content_title"/>
</LinearLayout>
</FrameLayout>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:theme="@style/ActionBarThemeOverlay"
app:popupTheme="@style/ActionBarPopupThemeOverlay"
app:layout_scrollFlags="scroll|enterAlways"
android:background="@drawable/gradient_bg" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="fill"
android:isScrollContainer="true"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content" …Run Code Online (Sandbox Code Playgroud) 我正在研究android应用程序.我正在使用的服务器为用户提供订阅功能,因此用户需要付款才能成为网站上的会员.
现在我在android应用程序中使用相同的工具并使用webview来执行支付网关.我正在webview中加载条带结帐付款的网址.
但是我在webview中收到Stripe checkout的以下错误.
抱歉,加载Checkout时出现问题.如果仍然存在,请尝试使用其他浏览器.
如何在Webview中解决此问题,以便它可以在我的应用程序中工作.
请帮助,如果有人知道这一点,这将是一个很大的帮助.
非常感谢先进.
我正在开发一个Android应用程序,并在我的应用程序中的许多地方使用Spinner.我想要的是更改所选微调器项目的背景颜色,以便可以轻松识别当前选择的项目.
我已经选中了这个链接设置选择的Spinner项目的背景颜色,但这样做会改变所选的textview背景颜色,但不要在下拉列表中更改它的颜色,我想在我看到时更改所选textview的背景颜色下拉列表.
我想更改列表中所选项目的颜色,而不是在微调器上,请参见下图.
非常感谢先进.
我夸大了使用listview的页面查看器的片段。并且列表视图在预棒棒糖设备中不支持setNestedScrollingEnabled。因此,我已在NestedScrollView中添加了listview,但是在滚动列表时不会滚动。
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:id="@+id/fragment_item_view"
android:background="@color/white"
android:isScrollContainer="true">
<ProgressBar
style="?android:attr/progressBarStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/progressBar"
android:layout_centerInParent="true" />
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/swipe_refresh_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="none"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:fillViewport="true">
<ListView
android:id="@+id/list_item_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical"
android:clipToPadding="false"
android:divider="@color/gray_stroke_color"
android:dividerHeight="0.5dp"
android:paddingBottom="@dimen/padding_64dp" >
</ListView>
</android.support.v4.widget.NestedScrollView>
</android.support.v4.widget.SwipeRefreshLayout>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
谁能建议我任何解决方案。提前致谢。
我用下面的代码创建了一个可绘制的文件:
<layer-list
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@color/gray_background"/>
<item
android:drawable="@color/light_green"
android:bottom="@dimen/event_button_bottom_color"/>
</layer-list>
Run Code Online (Sandbox Code Playgroud)
现在在运行时,我想以编程方式使用其他一些颜色更改第二个项目的可绘制颜色 (@color/light_green)。我该怎么做,如果有人知道如何实现这一点,请帮助。
非常感谢先进。:)
我有一个使用GlideImageView加载图像的图像。当我执行类似操作后,使用 通知回收器视图适配器。它会导致图像闪烁 2 次。有人能帮我一下吗。notifyItemChanged(position)
这部分代码在notifyItemChanged(position)调用时执行:
Glide.with(mContext)
.load(mainImage)
.placeholder(R.color.grey_light)
.diskCacheStrategy(DiskCacheStrategy.ALL)
.into(listItemHolder.mSingleAttachmentImage);
Run Code Online (Sandbox Code Playgroud)
提前致谢。