看起來你只是想不服務器演示目的本地顯示的消息,對不對?
首先,我並不認爲你應該在C#中學習Android,原因很多。首先,你需要Java來做Android開發。
這裏簡單的場景。
您有一項活動叫做MainActivity
,其中有兩個文本框叫做name
和email
。
現在,您將有一個按鈕叫submit
一旦用戶輸入姓名和電子郵件地址,並按下提交按鈕,將用戶帶到一個新的活動叫做WelcomeActivity
。
在android中,您需要一個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