0

基本上,当我SignInActivity从它开始时,MainActivity它会给我Activity顶部的标签,但是屏幕的其余部分是空白的。我不知道这是否与我的XML布局或什么有关,但我没有收到任何错误或任何东西。另一个奇怪的事情是,当我把 a 放进去时Log.e()SignInActivity它从来没有记录任何东西……很奇怪

 // OnCreate // ActivityMain
 //check prefs for the update on authenticatedGoogleAccount and staysignedin
    boolean authenticatedGoogleAccount = prefs.getBoolean("authenticatedGoogle_key", false);
    boolean staysignedin_isChecked = prefs.getBoolean("staysignedin_key",false);

    if(!authenticatedGoogleAccount || !staysignedin_isChecked){
        Intent e = new Intent(MainMenu_Activity.this,SignIn_Activity.class);
        startActivity(e);
    }

// OnCreate // SignInActivity
public void onCreate(Bundle savedInstanceState){
    super.onCreate(savedInstanceState);
    setContentView(R.layout.signin_page);
    Log.e("Hello from signin", "");
    verify_button = (Button) findViewById(R.id.verify_button);
    signin_button = (Button) findViewById(R.id.signin_button);

    link4help = (TextView) findViewById(R.id.link_to_register);

    gmail = (EditText) findViewById(R.id.signin_email);
    password = (EditText) findViewById(R.id.signin_password);

    email_success = (ImageView) findViewById(R.id.email_authenticate_success);
    password_success = (ImageView) findViewById(R.id.password_authenticate_success);

    email_success.setVisibility(View.INVISIBLE);
    password_success.setVisibility(View.INVISIBLE);

    signin_button.setEnabled(false);

    verify_button.setOnClickListener(this);
    signin_button.setOnClickListener(this);
    link4help.setOnClickListener(this);
}

--

//xml file from SignInActivity//
 <?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true" >
<RelativeLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="#ffffff">

    <!-- Header Starts  -->
    <LinearLayout android:id="@+id/header"
        android:orientation="horizontal"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="@layout/header_gradient"
        android:paddingTop="5dip"
        android:paddingBottom="5dip">

            <!-- Logo Start -->

            <TextView
                android:contentDescription="@string/contentDescriptionSignin"
                android:text="@string/WelcometoDictaShare"
                android:textColor="#ffffff"
                android:textSize="20sp"
                android:padding="10dp"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="10dip"/>
            <!-- Logo Ends -->
     </LinearLayout>
     <!-- Header Ends -->

     <!-- Footer Start -->
     <LinearLayout android:id="@+id/footer"
         android:orientation="horizontal"
         android:layout_width="fill_parent"
         android:layout_height="80dip"
         android:background="@layout/footer_repeat"
         android:layout_alignParentBottom="true">
     </LinearLayout>                
     <!-- Footer Ends -->

     <!-- Login Form -->
     <LinearLayout
      android:orientation="vertical"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:padding="10dip"
      android:layout_below="@id/header">

     <!-- ACCOUNT SIGN IN -->
      <TextView android:layout_width="fill_parent"
            android:paddingTop="15dp" 
            android:paddingLeft="2dp"         
            android:layout_height="wrap_content"
            android:textColor="#372c24"
            android:text="@string/account_title"/>
      <EditText  android:id="@+id/signin_account_name"
          android:layout_width="fill_parent"
            android:inputType="text"
            android:layout_height="wrap_content"
            android:layout_marginTop="5dip"
            android:layout_marginBottom="25dp"
            android:hint="@string/signin_hint"
            android:padding="12dp"
            android:minHeight="20dp"
            android:maxHeight="50dp"
            android:singleLine="true"
            android:background="@layout/borderedittext"/>

      <LinearLayout android:background="@layout/border"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:orientation="vertical"
          android:padding="10dp">

           <!-- Google LOGO -->
      <ImageView
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:contentDescription="@string/googlelogo"
          android:gravity="right"
          android:layout_gravity="right"
          android:src="@drawable/googlelogo" />


      <!--  Email Label -->
      <TextView android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:textColor="#372c24"
            android:text="@string/Email"
            android:paddingLeft="2dp"/>
      <LinearLayout
          android:layout_width="fill_parent"
          android:layout_height="match_parent"
          android:orientation="horizontal"
          android:weightSum="1">
          <EditText  android:id="@+id/signin_email"
              android:layout_width="fill_parent"
                android:inputType="textEmailAddress"
                android:layout_height="wrap_content"
                android:layout_marginTop="5dip"
                android:layout_marginBottom="10dip"
                android:singleLine="true"
                android:layout_weight=".5"
                android:padding="12dp"
                android:background="@layout/borderedittext"/>

          <ImageView android:id="@+id/email_authenticate_success"
              android:src="@drawable/navigation_accept"
              android:layout_width="wrap_content"
              android:layout_height="match_parent"
              android:contentDescription="@string/authenticationsuccess"
              android:layout_weight=".5"
              />
      </LinearLayout>
      <!--  Password Label -->


      <TextView android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:textColor="#372c24"
            android:text="@string/Password"
            android:paddingLeft="2dp"/>
      <LinearLayout
          android:layout_width="fill_parent"
          android:layout_height="match_parent"
          android:orientation="horizontal"
          android:weightSum="1">

          <EditText android:id="@+id/signin_password"
              android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="5dip"
                android:singleLine="true"
                android:inputType="textPassword"
                android:layout_weight=".5"
                android:padding="12dp"
                android:background="@layout/borderedittext"/>

          <ImageView android:id="@+id/password_authenticate_success"
                  android:src="@drawable/navigation_accept"
                  android:layout_width="wrap_content"
                  android:layout_height="match_parent"
                  android:contentDescription="@string/authenticationsuccess"
                  android:layout_weight=".5"
                  />
      </LinearLayout>

          <LinearLayout
              android:layout_height="wrap_content"
              android:layout_width="fill_parent"
              android:orientation="horizontal"
              android:weightSum="1">

          <!-- Authentication button -->
          <Button android:id="@+id/verify_button"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:paddingRight="3dp"
                android:paddingLeft="3dp"
                android:padding="5dp"
                android:textSize="12sp"
                android:gravity="center"
                android:layout_marginTop="10dip"
                android:text="@string/verify"
                android:background="@layout/borderbuttonverify"
                android:layout_weight=".1"/>
          <!-- Link to Registration Screen -->
          <TextView android:id="@+id/link_to_register"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="25dp"
                android:layout_marginBottom="25dp"
                android:text="@string/cantaccessyouracccount"
                android:gravity="center|bottom"
                android:textSize="12sp"
                android:textColor="#4d8ffc"
                android:layout_weight=".9"/>
          </LinearLayout>

      </LinearLayout>  


       <LinearLayout
              android:layout_height="wrap_content"
              android:layout_width="fill_parent"
              android:orientation="horizontal"
              android:weightSum="1"
               android:layout_marginTop="20dp">

          <Button android:id="@+id/signin_button"
                android:background="#4d8ffc"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/signin"
                android:layout_weight=".5"/>

          <CheckBox android:id="@+id/staysignedin"
              android:layout_width="wrap_content"
              android:layout_height="match_parent"
              android:layout_gravity="bottom|center"
              android:layout_weight=".5"
              android:text="@string/staysignedin"/>

       </LinearLayout>
     <!-- Login Form Ends -->
     </LinearLayout>



</RelativeLayout>    

4

1 回答 1

0

我在我的代码中尝试了你的 .xml(结构很像你的),因为我没有绘图或字符串资源,我用纯文本替换你的字符串,所有背景都使用白色,并删除了 imageview 的 src 引用。我在 OnCreate 中为 signin_activity 所做的唯一一件事就是将 setcontentview 设置为 signin_page.xml。当这样调用时,您的页面会出现所有文本字段。基于此,我的猜测可能是 xml 与您的 SetContentView 调用中的名称不匹配,或者 ImageViews 中的 src 链接有问题。像你一样,我没有用你的字符串得到 Log.e,但我把它改成了这个 Log.e("SigninActivity","Hello from signin"),它起作用了(也许 Log 不喜欢第一个参数?)
HTH

ps 和相关 - 您发布的代码中没有结束 ScrollView 标记

于 2013-08-09T22:40:36.690 回答