Presentation is loading. Please wait.

Presentation is loading. Please wait.

CMPE419 Mobile Application Development

Similar presentations


Presentation on theme: "CMPE419 Mobile Application Development"— Presentation transcript:

1 CMPE419 Mobile Application Development
Asst.Prof.Dr.Ahmet Ünveren SPRING Computer Engineering Department CMPE419 AU

2 Example:(Table Layout)

3 <TableLayout xmlns:android="http://schemas. android
xmlns:tools=" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.CMPE419.gpa.MainActivity" > <TableRow android:layout_width="wrap_content" android:layout_height="wrap_content" > <TextView android:layout_height="wrap_content" android:text="Name " /> <EditText android:layout_width="131dp" android:ems="10" /> </TableRow> android:text="Surname " /> android:layout_width="163dp" android:ems="10" > <requestFocus /> </EditText> ... </TableLayout>

4 <TableRow android:layout_width="wrap_content" android:layout_height="wrap_content" > android:text="Column 0" /> <Button android:layout_height="wrap_content" android:text="Button" /> </TableRow>

5 Get Values From EditText:
final EditText m1=(EditText)findViewById(R.id.editText3); final EditText m2=(EditText)findViewById(R.id.editText4); final EditText fin=(EditText)findViewById(R.id.editText5); String m11=m1.getText().toString(); mt1=Double.parseDouble(m11); String m22= m2.getText().toString(); mt2=Double.parseDouble(m22); //mt2=Double.valueof(m22); String fin2=fin.getText().toString(); fina=Double.parseDouble(fin2); double tot=mt1*0.25+mt2*0.25+fina*0.5;

6 Button b1=(Button)findViewById(R.id.button1);
b1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub String m11=m1.getText().toString(); mt1=Double.parseDouble(m11); String m22= m2.getText().toString(); mt2=Double.parseDouble(m22); //mt2=Double.valueof(m22); String fin2=fin.getText().toString(); fina=Double.parseDouble(fin2); double tot=mt1*0.25+mt2*0.25+fina*0.5; Tv.setText(""+tot); } });

7 Add Picture to your Project
Add a Picture: Step 1: Create a Project with main activity Step 2: Goto your Workspace directory and find your project name. Step 3: Open drawable-hdpi directory and copy your picture into this directory. Step 4: From Eclips menu select Project and than clean for recognizing picture. Step 5: Goto xml file and use properties and Background options to select your picture (Under Drawable)(If error occures restart Eclips).

8 Password Field:

9 Android radio buttons example:
In Android, you can use “android.widget.RadioButton” class to render radio button, and those radio buttons are usually grouped by android.widget.RadioGroup. If RadioButtons are in group, when oneRadioButton within a group is selected, all others are automatically deselected.

10

11 Intent and Moving Data between Activities
Step 1: Create MainActivity Step2: Create NewActivity Step3: Create new Intent in MainActivity Step4: Send your data from MainActivity using putExtra method Step5: Get data in NewActivity using getIntent().getExtras()

12

13 package com.example.cmpe; public class MainActivity extends Activity { EditText Et1_name; EditText protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Et1_name=(EditText)findViewById(R.id.editText1); Et2_surname=(EditText)findViewById(R.id.editText2); Button Bt=(Button)findViewById(R.id.button1); Bt.setOnClickListener(new View.OnClickListener() public void onClick(View v) { // TODO Auto-generated method stub //startActivity(new Intent("android.intent.action.MYNEW")); String name=Et1_name.getText().toString(); String surname=Et2_surname.getText().toString(); //Creating a new intent Intent intent=new Intent(MainActivity.this, MyNew.class); //Sending data to next activity using putExtra method intent.putExtra("NAME", name); intent.putExtra("SURNAME", surname); //starting new activity startActivity(intent); } }); }

14 package com.example.cmpe; public class MyNew extends protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.mynew); final TextView T1=(TextView)findViewById(R.id.textView2); final TextView T2=(TextView)findViewById(R.id.textView4); Bundle bunble=getIntent().getExtras(); if(bunble!=null){ //Getting the value stored in the name "NAME" String user_name=bunble.getString("NAME"); String user_surname=bunble.getString("SURNAME"); //appending the value to the contents of textView1. T1.append(" "+user_name); T2.append(" "+user_surname); } final Button b=(Button)findViewById(R.id.button1); b.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // TODO Auto-generated method stub finish(); }}); }}


Download ppt "CMPE419 Mobile Application Development"

Similar presentations


Ads by Google