我想为我的应用程序创建一个屏幕,允许用户创建用户名,然后启动应用程序。我已经拥有了一个我想让用户做的所有事情的屏幕,但是我现在想添加一个用户在进入活动屏幕之前必须使用的登录屏幕。我设计了登录屏幕,并准备好一个单独的课程。 Doe的任何人都知道如何解决这个问题,以便MainActivity首先加载登录信息?我假设我需要设置某种布尔标志,允许Main加载应用程序的其余部分?创建用户名和启动应用程序
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.login);
setContentView(R.layout.activity_main);
Size = (SeekBar)findViewById(R.id.size);
Speed =(SeekBar)findViewById(R.id.speed);
Agility=(SeekBar)findViewById(R.id.agility);
Vision =(SeekBar)findViewById(R.id.vision);
text = (TextView) findViewById(R.id.text);
Size.setOnSeekBarChangeListener(this);
Speed.setOnSeekBarChangeListener(this);
Agility.setOnSeekBarChangeListener(this);
Vision.setOnSeekBarChangeListener(this);
}
我有我的登录设置内容视图。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/login"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin">
<Button
android:text="Begin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/begin"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="124dp" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textPersonName"
android:text="Name"
android:ems="10"
android:layout_above="@+id/begin"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_marginRight="88dp"
android:layout_marginEnd="88dp"
android:layout_marginBottom="149dp"
android:id="@+id/editText2" />
</RelativeLayout>
我有我的布局。我也有班级,现在是空的。
我将不得不在我的AndroidManifest内部做些什么?
不客气。请删除这个答案。你可能打算评论,而不是错误地回答。顺便说一句,你可以将我的答案标记为接受,如果它的工作。 :) – tahsinRupam