小编Far*_*zad的帖子

Android:GoogleIdTokenVerifier.Builder中的transport和jsonFactory是什么?

在吹码中,什么是transport和jsonFactory?(我不明白)

https://developers.google.com/identity/sign-in/android/backend-auth#using-a-google-api-client-library

import com.google.api.client.googleapis.auth.oauth2.GoogleIdToken;
import com.google.api.client.googleapis.auth.oauth2.GoogleIdToken.Payload;
import com.google.api.client.googleapis.auth.oauth2.GoogleIdTokenVerifier;

...

GoogleIdTokenVerifier verifier = new GoogleIdTokenVerifier.Builder(transport /**Here**/, jsonFactory /**Here**/)
.setAudience(Arrays.asList(CLIENT_ID))
// If you retrieved the token on Android using the Play Services 8.3 API or newer, set
// the issuer to "https://accounts.google.com". Otherwise, set the issuer to 
// "accounts.google.com". If you need to verify tokens from multiple sources, build
// a GoogleIdTokenVerifier for each issuer and try them both.
.setIssuer("https://accounts.google.com")
.build();

// (Receive idTokenString by HTTPS POST)

GoogleIdToken …
Run Code Online (Sandbox Code Playgroud)

android authorization google-api-java-client android-studio google-signin

23
推荐指数
3
解决办法
5687
查看次数

Android设置在顶部和底部listview上淡化alpha渐变,如instagram实时聊天

如何扩展listview(或recyclerview)设置顶部底部渐变淡化alpha?

在此输入图像描述

编辑:

问题:

在此输入图像描述

xml布局:

<RelativeLayout>

    <ImageView /> // background image example: my_image.png (mach_parent)

    <ListView>
    </ListView>

</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

android listview android-recyclerview

13
推荐指数
1
解决办法
3716
查看次数

在ImageView上的android setAlpha进入CollapsingToolbarLayout不起作用

在CollapsingToolbarLayout imageview里面,我需要setAlpha(float)当它向上和向下滚动时:

这是获取偏移的方法,并按偏移计算浮动:

AppBarLayout.OnOffsetChangedListener:

 @Override
    public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
        float offsetAlpha = (float) (verticalOffset / appBarLayout.getTotalScrollRange());
        imageView.setAlpha(offsetAlpha);
    }
Run Code Online (Sandbox Code Playgroud)

xml布局:

 <android.support.design.widget.CollapsingToolbarLayout
            android:id="@+id/collapsingToolbarLayout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:minHeight="50dp"
            android:fitsSystemWindows="true"
            app:layout_scrollFlags="scroll|exitUntilCollapsed"
            app:contentScrim="@android:color/transparent">

      <ImageView
                    android:id="@+id/imageView"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_gravity="center"
                    android:scaleType="centerCrop"
                    app:layout_collapseMode="parallax" />

 </android.support.design.widget.CollapsingToolbarLayout>
Run Code Online (Sandbox Code Playgroud)

但是setAlpha不起作用.为什么?

android android-layout android-coordinatorlayout

5
推荐指数
1
解决办法
1342
查看次数

显示对话框片段时未调用 Android dispatchKeyEvent

当我的对话片段是hide,dispatchKeyEvent工作正常

@Override
public boolean dispatchKeyEvent(KeyEvent event) {

    Toast.makeText(FragmentPlayer.this, "test: called", Toast.LENGTH_SHORT).show();

    return super.dispatchKeyEvent(event);

}
Run Code Online (Sandbox Code Playgroud)

但是当我的对话片段是show,dispatchKeyEvent没有被调用

MyDialogFragment mFragment = new MyDialogFragment();
mFragment.show(getSupportFragmentManager(), "MyDialog");
Run Code Online (Sandbox Code Playgroud)

为什么?

android android-fragments android-dialogfragment

5
推荐指数
1
解决办法
3045
查看次数

Android Studio:错误:类型为styleable [ResourceType]的预期资源

在android studio中,当我想生成签名的apk时,导致以下错误:

Error:Error: Expected resource of type styleable [ResourceType]

这个类是:https://github.com/astuetz/PagerSlidingTabStrip

我该如何修复错误?

PagerSlidingTabStrip 类:

import android.annotation.SuppressLint;
    import android.content.Context;
    import android.content.res.TypedArray;
    import android.graphics.Canvas;
    import android.graphics.Paint;
    import android.graphics.Paint.Style;
    import android.graphics.Typeface;
    import android.os.Build;
    import android.os.Parcel;
    import android.os.Parcelable;
    import android.support.v4.view.ViewPager;
    import android.support.v4.view.ViewPager.OnPageChangeListener;
    import android.util.AttributeSet;
    import android.util.DisplayMetrics;
    import android.util.TypedValue;
    import android.view.Gravity;
    import android.view.View;
    import android.view.ViewTreeObserver.OnGlobalLayoutListener;
    import android.widget.HorizontalScrollView;
    import android.widget.ImageButton;
    import android.widget.LinearLayout;
    import android.widget.TextView;

    import java.util.Locale;

    public class PagerSlidingTabStrip extends HorizontalScrollView {

        public interface IconTabProvider {
            public int getPageIconResId(int position);
        }

        // @formatter:off
        private …
Run Code Online (Sandbox Code Playgroud)

android android-resources android-studio

4
推荐指数
1
解决办法
6908
查看次数

Android studio 3无法下载存储库(错误:无法下载资源的SHA1)

我使用android studio 3.0.0版.

更新之前我使用SDK管理器更新支持库.但更新后的android studio 3我应该通过更新https://dl.google.com/dl/android/maven2/.所以我需要支持库26.1.0.

在async gradle上我有这个错误:

Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve junit:junit:4.12.

Could not resolve junit:junit:4.12.
Required by:
    project :app > com.android.support.test:runner:1.0.1
 > Could not resolve junit:junit:4.12.
    > Failed to download SHA1 for resource 'https://dl.google.com/dl/android/maven2/junit/junit/4.12/junit-4.12.pom'.
          > For input string: "<!"
Run Code Online (Sandbox Code Playgroud)

为什么不能下载这个:https://dl.google.com/dl/android/maven2/junit/junit/4.12/junit-4.12.pom?

我使用代理但无法下载.

这个错误显示所有依赖库(appcampatv7,设计,annonations等)

如何解决此问题无法下载资源的SHA1?

更新:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {

    repositories {
        google()
        jcenter()
    }
    dependencies { …
Run Code Online (Sandbox Code Playgroud)

android android-support-library android-studio android-gradle-plugin

3
推荐指数
1
解决办法
2150
查看次数

Android:在onBindViewHolder中输入setOnclickListener或setOnLongClickListener是否正确?

我可以在onBindViewHolder中放置setOnclickListener或setOnLongClickListener吗?

onBindViewHolder写这个方法没问题?(是否明智?)

还是ViewHolder写得更好?

public void onBindViewHolder(ViewHolder holder, int position) {


    myBtn.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            //...
        }
    }); }
Run Code Online (Sandbox Code Playgroud)

这种方法对RecyclerView列表的速度有不良影响?

android view android-viewholder android-recyclerview

1
推荐指数
1
解决办法
1512
查看次数

php mysql 如何用php检查NULL列

如何NULL用php检查mysql列变量?

我的行表(示例):

1 ---- james ------ italy

2 ---- joyee ------ NULL

我从表中获取数组:

$rows[0] = array('name' => 'james', 'country' => 'italy');
$rows[1] = array('name' => 'joyee', 'country' => NULL);
Run Code Online (Sandbox Code Playgroud)

但我的问题:

如何检查 NULL 数组元素:

foreach($rows as $row) {

     if ($row['country'] == NULL) echo "country is null"; // not working
     if ($row['country'] == '') echo "country is null"; // not working
     if (is_null($row['country'])) echo "country is null"; // not working
     if (empty($row['country'])) echo "country is null"; // not working
     // …
Run Code Online (Sandbox Code Playgroud)

php mysql arrays mysqli

1
推荐指数
1
解决办法
1983
查看次数