Linux - How to alert a message, Alert text message in android
How to alert a message
In Xml code create the button then call the onclick event function in java<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: paddingBottom="@dimen/activity_vertical_margin" android: paddingLeft="@dimen/activity_horizontal_margin" android: paddingRight="@dimen/activity_horizontal_margin" android: paddingTop="@dimen/activity_vertical_margin" tools:context=".MainActivity" > <EditText android:id="@+id/mnum" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_above="@+id/button1" android:layout_alignParentLeft="true" android:layout_marginBottom="30dp" android:layout_marginLeft="96dp" android:ems="10" /> <Button android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignLeft="@+id/email" android:layout_alignParentTop="true" android:layout_marginLeft="46dp" android:layout_marginTop="170dp" android:onClick="searchInUrl" android:text="@string/button1" /> </RelativeLayout>
In MainActivity.java
package com.firstapp;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
public class MainActivity extends Activity {
public EditText mnum,memail;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void searchInUrl(View clickedButton) {
mnum = (EditText)findViewById(R.id.mnum); // Get id of text box
String mnumval= mnum.getText().toString();// Get the value of text box
Toast.makeText(getApplicationContext(), memailval+"-#"+mnumval, Toast.LENGTH_SHORT).show(); // alert the value of textbox
}
The topic on Linux - How to alert a message is posted by - Math
Hope you have enjoyed, Linux - How to alert a messageThanks for your time