私は自分のアプリにFacebookを実装しようとしています。私はFacebookの開発者サイトからの指示に従っていましたが、完全には説明されなかったステップにかかってしまいました。私の場合は、彼らが何を話しているのか分かっていました。facebook loginbuttonでレンダリングの問題を解決するには?
いずれにせよ、私はfacebook sdkを追加し、必要に応じてすべての予備ステップを実行しました。しかし、facebook loginbuttonをgameconsole.xmlに追加してアンドロイドスタジオのデザインビューに切り替えようとすると、レンダリングエラーが発生します。
は、ここで私がどこかで読んだfacebook.sdkinitializeはUIが動作するために最初に呼び出されなければならないというのが私のgameconsole.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:id="@+id/gameconsole_bg">
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="30dp"
android:maxHeight="325dp"
android:adjustViewBounds="true"
/>
<EditText
android:id="@+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/imageView1"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:capitalize="characters"
android:ems="10"
android:gravity="center" />
<TextView
android:id="@+id/editText2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/imageButton2"
android:layout_centerHorizontal="true"
android:layout_marginTop="97dp"
android:ems="5"
android:visibility="invisible"
/>
<TextView
android:id="@+id/editText3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/editText2"
android:layout_below="@+id/imageButton2"
android:ems="5"
android:visibility="invisible"
/>
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/imageView1"
android:layout_centerHorizontal="true"
android:text="@string/pc1"
android:textSize="12sp"
android:textColor="#ffffff" />
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/help"
android:id="@+id/imageButton3"
android:layout_above="@+id/editText2"
android:layout_toLeftOf="@+id/editText3"
android:layout_toStartOf="@+id/editText3" />
<ImageButton
android:id="@+id/imageButton2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/rateus"
android:layout_marginTop="60dp"
android:layout_below="@+id/editText1"
android:layout_toRightOf="@+id/editText3"
android:layout_toEndOf="@+id/editText3" />
<com.facebook.login.widget.LoginButton
android:id="@+id/login_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:layout_marginBottom="30dp" />
</RelativeLayout>
ですか?いいよ。私はこのコードをアプリケーションコードに入れます
import android.app.Application;
import com.facebook.FacebookSdk;
import com.facebook.appevents.AppEventsLogger;
public class MyApp extends Application {
@Override
public void onCreate() {
super.onCreate();
// Initialize the SDK before executing any other operations,
FacebookSdk.sdkInitialize(getApplicationContext());
AppEventsLogger.activateApp(this);
本当に私の本当の疑問は何ですか?私はプログラムを実行していないので、まだ何も初期化されていません。私は、プログラムが実行される前にデザインモードでボタンを追加しようとしています。デザインモードでは、プログラムが実行されていないか、間違っていますか?私はまだプログラミングに新しいです、これは私に頭痛を与えています。どんな助けもありがとう。