Presentation is loading. Please wait.

Presentation is loading. Please wait.

BLP 4216 MOBİL UYGULAMA GELİŞTİRME-2

Similar presentations


Presentation on theme: "BLP 4216 MOBİL UYGULAMA GELİŞTİRME-2"— Presentation transcript:

1 BLP 4216 MOBİL UYGULAMA GELİŞTİRME-2
Dr. Aslı Ergün 1

2 BMI Ornek

3 <. xml version="1. 0" encoding="utf-8"
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=" xmlns:app=" xmlns:tools=" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#E1C58E" tools:context=".MainActivity"> <LinearLayout android:layout_height="wrap_content" android:orientation="vertical" android:layout_marginTop="80dp"> <TextView android:layout_width="wrap_content" android:text="BMI HESAPLAMA" android:textSize="24sp" android:textStyle="bold" android:layout_gravity="center" /> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:layout_marginTop="30dp"> <TextView android:layout_width="50dp" android:layout_marginStart="30dp" /> <EditText android:hint="Kilo" android:inputType="number" /> </LinearLayout>

4 <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal"> <TextView android:layout_width="50dp" android:layout_marginStart="30dp" /> <EditText android:hint="Boy" android:inputType="number" </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal"> <TextView android:layout_width="50dp" android:layout_marginStart="30dp" /> <EditText android:hint="Yaş" android:inputType="number" </LinearLayout>

5 <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> <RadioGroup android:layout_width="wrap_content" android:orientation="horizontal" android:layout_marginTop="30dp" android:layout_gravity="center"> <RadioButton android:text="Kadın" /> <RadioButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginStart="30dp" android:text="Erkek" /> </RadioGroup> <Button android:layout_marginTop="30dp" android:layout_gravity="center" android:text="HESAPLA" <TextView </LinearLayout>

6 Mainactivity.java public class MainActivity extends AppCompatActivity { Button butonhesap; TextView tv_ideal; EditText kilo; EditText boy; EditText yas; RadioGroup rdgrup; RadioButton k; RadioButton e; float protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); kilo = findViewById(R.id.kilo); boy = findViewById(R.id.boy); yas = findViewById(R.id.yas); tv_ideal = findViewById(R.id.ideal); rdgrup = findViewById(R.id.rdgroup); k = findViewById(R.id.kadin); e = findViewById(R.id.erkek); butonhesap = findViewById(R.id.button); butonhesap.setOnClickListener(new View.OnClickListener() {

7 Mainactivity.java 27.05.2019 @Override
public void onClick(View view) { int secilenRadio= rdgrup.getCheckedRadioButtonId(); switch(secilenRadio) { case(R.id.kadin): katsayi =0.8f; break; case(R.id.erkek): katsayi =0.9f; default: Toast.makeText(MainActivity.this, "Secim yapılmalı", Toast.LENGTH_SHORT).show(); } float b = Float.parseFloat(boy.getText().toString()); float y =Float.parseFloat(yas.getText().toString()); float k =Float.parseFloat(kilo.getText().toString()); float ideal = (b y / 10) * katsayi; tv_ideal.setText(Float.toString(ideal)); if (ideal<k) Toast.makeText(MainActivity.this, "Kilolu", Toast.LENGTH_LONG).show(); else if(ideal>k) Toast.makeText(MainActivity.this, "Zayıf", Toast.LENGTH_LONG).show(); else Toast.makeText(MainActivity.this, "Normal", Toast.LENGTH_LONG).show(); });

8 Camera App

9 Activity_main.xml <LinearLayout xmlns:android=" xmlns:app=" xmlns:tools=" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:layout_margin="20dp" tools:context=".MainActivity"> <LinearLayout android:layout_height="wrap_content" android:orientation="vertical"> <VideoView android:layout_height="150dp" /> <ImageView android:layout_marginTop="20dp" /> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal"> <Button android:layout_width="150dp" android:layout_height="60dp" android:text="Video Çek" android:layout_gravity="center" app:layout_constraintEnd_toEndOf="parent" android:layout_margin="20dp" /> android:text="Fotograf Cek" </LinearLayout>

10 AndroidManifest.xml <manifest xmlns:android=" package="com.example.myapplication19"> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.RECORD_AUDIO" /> <application android:allowBackup="true" android:supportsRtl="true" <activity android:name=".MainActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application>

11 MainActivity.java public class MainActivity extends AppCompatActivity { Button fotografcek; Button videocek; private static final int VIDEO_ACTION_CODE = 101; private static final int IMAGE_ACTION_CODE = protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); fotografcek = findViewById(R.id.fotocek); videocek = findViewById(R.id.videocek); fotografcek.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { takePhoto(); } }); videocek.setOnClickListener(new View.OnClickListener() { recordVideo(); public void takePhoto() { Intent fotointent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); startActivityForResult(fotointent, IMAGE_ACTION_CODE); } public void recordVideo() { Intent videointent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE); startActivityForResult(videointent, VIDEO_ACTION_CODE); @Override protected void onActivityResult(int requestCode, int Intent data) { super.onActivityResult(requestCode, resultCode, data); if (resultCode != RESULT_OK) return; switch (requestCode) { case VIDEO_ACTION_CODE: VideoView videoV = findViewById(R.id.videoView); videoV.setVideoURI(data.getData()); videoV.setMediaController(new MediaController(this)); videoV.requestFocus(); videoV.start(); break; case IMAGE_ACTION_CODE: Bundle extras = data.getExtras(); ImageView img = findViewById(R.id.imageView); img.setImageBitmap((Bitmap) extras.get("data")); default: } }


Download ppt "BLP 4216 MOBİL UYGULAMA GELİŞTİRME-2"

Similar presentations


Ads by Google