Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/217.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 自定义首选项类中的onResume等效项?_Java_Android_Android Preferences - Fatal编程技术网

Java 自定义首选项类中的onResume等效项?

Java 自定义首选项类中的onResume等效项?,java,android,android-preferences,Java,Android,Android Preferences,我有一个自定义的首选项类,它显示一个PlusOne按钮。根据Google文档,我需要在Activity类的onResume函数中初始化这个按钮。在偏好类中,什么是等价物?每次重新加载视图时,我可以使用什么函数刷新视图?我在谷歌上搜索了一个答案,但运气不好。所以我想出了如何让Google+plusOn按钮工作,并同步多个plus按钮的数量 在设置活动onCreate中,设置设置的自定义布局 setContentView(R.layout.custom_layout); 您的自定义布局应如

我有一个自定义的首选项类,它显示一个PlusOne按钮。根据Google文档,我需要在Activity类的onResume函数中初始化这个按钮。在偏好类中,什么是等价物?每次重新加载视图时,我可以使用什么函数刷新视图?我在谷歌上搜索了一个答案,但运气不好。

所以我想出了如何让Google+plusOn按钮工作,并同步多个plus按钮的数量

在设置活动onCreate中,设置设置的自定义布局

    setContentView(R.layout.custom_layout);
您的自定义布局应如下所示:

    <LinearLayout 
        android:orientation="vertical" 
        android:background="@drawable/backgroundone" 
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent"
        xmlns:android="http://schemas.android.com/apk/res/android"
 xmlns:plus="http://schemas.android.com/apk/lib/com.google.android.gms.plus"
 >




<ListView 
    android:id="@+id/android:list" 
    android:layout_width="fill_parent" 
    android:layout_height="0.0dip" 
    android:cacheColorHint="#00000000" 
    android:layout_weight="1.0" />



<RelativeLayout
    android:layout_width="fill_parent"
    android:layout_height="30dp"
    android:layout_marginBottom="25dp" >



    <com.google.android.gms.plus.PlusOneButton
        android:id="@+id/plus_one_medium_button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_alignParentBottom="true"
        android:layout_marginRight="10sp"
        plus:size="medium" >
    </com.google.android.gms.plus.PlusOneButton>
</RelativeLayout>
现在将onResume方法添加到设置活动中:

  @Override
  protected void onResume()
  {
    super.onResume();
    mPlusOneMediumButton.initialize(URL, PLUS_ONE_REQUEST_CODE);
  }
URL是您的应用程序在Google Play上的URL

根据开发人员文档,请求代码应为0。

试试看,它可能会帮助您解决问题。
  @Override
  protected void onResume()
  {
    super.onResume();
    mPlusOneMediumButton.initialize(URL, PLUS_ONE_REQUEST_CODE);
  }