我想为应用创建一个登录页面。但是,活动并未显示其唯一的空白页面,其中包含一个带有应用程序名称的标题栏。我尝试了不同的主题,但问题仍然存在。
这是我的清单文件:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="variofitness.com.schedulekeeper">
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<application
android:allowBackup="true"
android:icon="@mipmap/img_logo"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".HomeActivity"
android:label="@string/app_name"
android:theme="@style/Theme.AppCompat.NoActionBar">
</activity>
<activity android:name=".LoginActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
这是我的样式文件
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/white</item>
<item name="android:textColorPrimary">@color/lightBlue</item>
<item name="android:windowBackground">@color/white</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
<style name="ToolBarStyle" parent="">
<item name="android:background">@android:color/transparent</item>
<item name="titleTextAppearance">?android:textAppearanceLarge</item>
</style>
<style name="ThemeOverlay.MyApp.ActionBar" parent="ThemeOverlay.AppCompat.ActionBar">
<!-- Parent theme sets colorControlNormal to textColorPrimary. -->
<item name="android:textColorPrimary">@color/lightBlue</item>
</style>
</resources>
这是我的java代码..
package variofitness.com.schedulekeeper;
import android.os.Bundle;
import android.os.PersistableBundle;
import android.support.design.widget.TextInputLayout;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
/**
* Created by vinod on 1/29/16.
*/
public class LoginActivity extends AppCompatActivity implements View.OnClickListener{
EditText edtUserName,edt_password;
TextInputLayout input_application_password,input_application_userName;
TextView txt_Forgot_Password;
Button btn_login,btn_request_For_signUp;
@Override
public void onCreate(Bundle savedInstanceState, PersistableBundle persistentState) {
super.onCreate(savedInstanceState, persistentState);
setContentView(R.layout.layout_login);
initializeComponents();
}
private void initializeComponents() {
input_application_password = (TextInputLayout)findViewById(R.id.input_application_password);
input_application_userName = (TextInputLayout)findViewById(R.id.input_application_userName);
edtUserName = (EditText)findViewById(R.id.edtUserName);
edt_password = (EditText)findViewById(R.id.edt_password);
txt_Forgot_Password = (TextView)findViewById(R.id.txt_Forgot_Password);
btn_login = (Button)findViewById(R.id.btn_login);
btn_request_For_signUp = (Button)findViewById(R.id.btn_request_For_signUp);
}
@Override
public void onClick(View view) {
switch (view.getId()){
case R.id.txt_Forgot_Password:
break;
case R.id.btn_login:
break;
case R.id.btn_request_For_signUp:
break;
default:
break;
}
}
}
任何人都可以帮我告诉我我错过了什么吗?
答案 0 :(得分:2)
@Override
public void onCreate(Bundle savedInstanceState, PersistableBundle persistentState) {
super.onCreate(savedInstanceState, persistentState);
用
替换这段代码@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
你很高兴。