基本上,当我从SignInActivity
开始MainActivity
时,它会在顶部给我Activity
标签,但屏幕的其余部分为空白。我不知道它是否与我的XML
布局有关,或者我没有得到任何错误或任何内容。另一个奇怪的事情是,当我在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>
答案 0 :(得分:0)
我在我的代码中尝试了你的.xml(结构与你的很相似),因为我没有绘图或字符串资源,我用字符串替换纯文本,所有背景都使用白色,并删除了src引用用于imageview。我在OnCreate中为signin_activity做的唯一一件事是signin_page.xml的setcontentview。当这样调用时,您的页面会显示所有文本字段。基于此,我的猜测是,你的SetContentView调用中的xml与名称不匹配,或者ImageViews中的src链接可能存在问题。
和你一样,我没有用你的字符串获取Log.e,但是我把它改成了这个Log.e(“SigninActivity”,“你好来自登录”),它起作用了(也许Log不喜欢第一个参数?)
HTH
P.S。和相关 - 您发布的代码中没有结束的ScrollView标记