Похоже, вы просто хотите, чтобы отобразить сообщение локально, без сервера для демонстрационной цели, не так ли?
Ну, в первую очередь, я не думаю, что вы должны изучить Android на C# по многим причинам. Прежде всего, для разработки Android требуется Java.
Вот простой сценарий.
У вас есть одна деятельность под названием MainActivity
, где у вас есть два текстовых поля: name
и email
.
Вы теперь кнопка под названием submit
После того, как пользователь вводит имя и адрес электронной почты и прессы Submit кнопку, он будет принимать пользователя на новый вид деятельности называется WelcomeActivity
.
В андроиде вам нужен файл xml, который устанавливает макет вашей деятельности. Я назову это activity_email.xml
.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context="com.maxphone.LoginActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Signup for email"
android:id="@+id/welcomeTextView"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true"
android:layout_marginStart="40dp"
android:layout_marginTop="20dp" />
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_centerHorizontal="true"
android:layout_below="@+id/welcomeTextView"
android:layout_marginTop="15dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Name"
android:id="@+id/usrnameTextView"
android:layout_marginTop="20dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/userEditText"
android:layout_marginTop="20dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:maxLines="1"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Email Address"
android:id="@+id/emailTextView"
android:layout_marginTop="20dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/emailEditText"
android:layout_marginTop="20dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:focusableInTouchMode="true"
android:maxLines="1"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/email_signed_up_smg"
android:id="@+id/loginErrorMsg"
android:layout_gravity="center_horizontal|end"
android:layout_marginTop="10dp"
android:layout_marginEnd="10dp"
android:singleLine="false"
android:textColor="#ffff0000"
android:visibility="invisible" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Login"
android:id="@+id/signupConfirmBtn"
android:layout_gravity="center_horizontal"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="40dp" />
</LinearLayout>
</RelativeLayout>
Теперь в вашем MainActivity
,
public class MainActivity extends Activity{
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
setContentView(R.layout.activity_login);
TextView txt = (TextView) findViewById(R.id.welcomeTextView);
txt.setTextSize(40);
final EditText usrname = (EditText) findViewById(R.id.userEditText);
final EditText email = (EditText) findViewById(R.id.emailEditText);
final TextView errorMsg = (TextView) findViewById(R.id.emailConfirmMsg);
final Button submitBtn = (Button) findViewById(R.id.emailConfirmBtn);
// Login Up button behavior
submitBtn.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// Staring MainActivity
Intent i = new Intent(getApplicationContext(), WelcomeActivity.class);
startActivity(i);
finish();
}
}
}
}
Этот класс будет отображать Views
(такие как представления текста, редактирование текстов и т.д.) и слушать поведение пользователя. Как только щелчок submitBtn
, он создаст намерение (пожалуйста, сделайте исследование) и возьмите пользователя к новому действию, которое определено в намерении.
и вы можете делать аналогичную работу для WelcomeActivity
для отображения приветственных сообщений, таких как Спасибо за регистрацию! и тому подобное.
Все это делается локально и не требует какой-либо деятельности в Интернете. Так что это в основном для демонстрационной цели.
Удачи вам!
Это немного расплывчато. Вы пытаетесь вернуть уведомление в приложение, чтобы проверить, что они зарегистрированы? Если нет сервера, откуда он должен оправиться? – nukeforum
Да, я знаю, что нет контакта с сервером. Вот почему я спрашиваю, могу ли я сделать это без него. Даже отправка электронной почты без запроса пользователя для входа будет приемлемой. – Eidenai
Как регистрируется человек за что-либо, если с сервером не связывается? – nukeforum