KaloriHesaplama Hepsini indir

package com.example.ali.kalorihesaplama;

import android.content.ContentValues;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;

import java.util.ArrayList;
import java.util.List;

import kaloriler.Kalori;
import list.listadepter;
import veritabani.DB;

public class MainActivity extends AppCompatActivity implements View.OnClickListener,AdapterView.OnItemClickListener {
    Intent frm;
    static   DB katman;
    static  SQLiteDatabase db;
    static   Spinner  curun,gunurun,cins;
    ListView list;
    EditText miktar;
    TextView genelt,topkalori;
    List<Kalori> liste;
    static ArrayList<String> clist,gunlist,cinsiyet;
    static  ArrayList<Integer> urunid,id,gunurun_id;
    static ArrayAdapter<String> cadp,gunadp,cinsadp;
 public  Button btn;
    Context contex;
    int[] btnid={R.id.btnekle,R.id.btnurun,R.id.btn_kalori};
    int[] text={R.id.tboy,R.id.tyas,R.id.tkilo};
    EditText[] jtext;
    EditText jtext_gun;
    double[] degerler;
    listadepter adp;
    AlertDialog.Builder dialog;
    LinearLayout layout;




    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        katman=new DB(this);
        contex=this;
        jtext=new EditText[text.length];
        degerler=new double[jtext.length];
        topkalori=(TextView)findViewById(R.id.genelkalori);
        for(int i=0;i<btnid.length;i++)
        {
            btn=(Button)findViewById(btnid[i]);
            btn.setOnClickListener(this);
        }
       for(int i=0;i< text.length;i++)
       {
           jtext[i]=(EditText)findViewById(text[i]);
           jtext[i].setText(i+1+"");
       }

        miktar=(EditText)findViewById(R.id.tmiktar);
        list=(ListView)findViewById(R.id.lis);
        curun=(Spinner)findViewById(R.id.curun);
        urunid=new ArrayList<Integer>();
         id=new ArrayList<Integer>();
        clist=new ArrayList<String>();
        cins=(Spinner)findViewById(R.id.cins);
        cinsiyet=new ArrayList<String>();
        cinsadp=new ArrayAdapter<String>(this,android.R.layout.simple_spinner_item,cinsiyet);
        cins.setAdapter(cinsadp);
        cinsadp.add("Erkek");
        cinsadp.add("Kadın");


         genelt=(TextView)findViewById(R.id.toplam);
        cadp=new ArrayAdapter<String>(this,android.R.layout.simple_spinner_item,clist);
        liste=new ArrayList<Kalori>();
        adp=new listadepter(this,liste);
        list.setAdapter(adp);
        curun.setAdapter(cadp);
        spinnerdoldur(contex);
        datagetir();
        toplam();
        list.setOnItemClickListener(this);
    }
    public void toplam(){
        double gtoplam=0.0;
        for(int i=0;i<adp.getCount();i++)
        {
            Kalori k=liste.get(i);
            gtoplam+=k.toplam;
        }
        gtoplam=virgul(gtoplam);
        genelt.setText("Toplam="+gtoplam);
    }
    public static void baglan(){
        db=katman.getWritableDatabase();
    }
    public boolean kontrolet()
    {
        int sayac=0;
        for(int i=0;i<jtext.length;i++) {
            if (jtext[i].getText().length() > 0) {
                try {
                    degerler[i] =Double.parseDouble(jtext[i].getText()+"");
                } catch (Exception ex) {
                    Toast.makeText(this,"Lütfen değerleri doğru giriniz!!!",Toast.LENGTH_LONG).show();
                    break;
                }
                sayac++;
            }
             else
                 break;
        }
    if(sayac==jtext.length)
        return true;
    return false;
    }
    public void ekle()
    {
        try {
            baglan();
            long secilen=curun.getSelectedItemId();
            int id=urunid.get((int)secilen);
            if(secilen>-1&&miktar.getText().length()>0&&kontrolet()){
                double kmiktar=Double.parseDouble(miktar.getText()+"");
                ContentValues par=new ContentValues();
                par.put("Urunid",id);
                par.put("Miktar",kmiktar);
                db.insertOrThrow("Kalori",null,par);
                katman.close();
                datagetir();

            }
        }catch(Exception ex){
            Toast.makeText(this,ex.getMessage(),Toast.LENGTH_LONG).show();

        }
    }

    public void sil(int id)
    {
        try {
            baglan();
            db.delete("Kalori","id=?",new String[]{id+""});
            katman.kapat();
            datagetir();
        }catch(Exception ex){
            Toast.makeText(this,ex.getMessage(),Toast.LENGTH_LONG).show();

        }

    }
    public void duzenle(int id,double miktar,int urun_id)
    {
        try {
             baglan();
             ContentValues par=new ContentValues();
             par.put("Urunid",urun_id);
             par.put("Miktar",miktar);
             db.update("Kalori",par,"id=?",new String[]{id+""});
            katman.kapat();
            datagetir();
        }catch(Exception ex){
            Toast.makeText(this,ex.getMessage(),Toast.LENGTH_LONG).show();

        }
    }

    public static void spinnerdoldur(Context context)
    {
        try{
            baglan();
            Cursor c=db.query("Urun",new String[]{"id","Urunad"},null,null,null,null,null);
            clist.clear();
            cadp.notifyDataSetChanged();
            urunid.clear();
            c.moveToPosition(-1);
            while(c.moveToNext())
            {
                cadp.add(c.getString(1));
                urunid.add(c.getInt(0));

            }
            c.close();
            katman.close();
        }catch(Exception ex){
            Toast.makeText(context,ex.getMessage(),Toast.LENGTH_LONG).show();
        }
    }
    public void datagetir(){
        try {
           baglan();
            Cursor isaretci=db.rawQuery("select k.id,u.Urunad,k.Miktar,u.Kalori,(u.Kalori*k.Miktar) from Kalori k inner join Urun u on u.id=k.Urunid ",null);
            liste.clear();
            adp.notifyDataSetChanged();
            id.clear();
            isaretci.moveToPosition(-1);
            while(isaretci.moveToNext())
            {
                id.add(isaretci.getInt(0));
                Kalori k=new Kalori();
                k.urunad=isaretci.getString(1);
                k.miktar=isaretci.getDouble(2);
                k.kalori=isaretci.getDouble(3);
                k.toplam=virgul(isaretci.getDouble(4));
                liste.add(k);
            }
            isaretci.close();
            katman.close();
            toplam();
        }catch(Exception ex){
            Toast.makeText(this,ex.getMessage(),Toast.LENGTH_LONG).show();
        }

    }
    public void frm2()
    {
        frm=new Intent(this, Main3Activity.class);
        startActivity(frm);

    }
    @Override
    public void onClick(View view) {
        switch (view.getId()){
            case R.id.btnekle:ekle();break;
            case R.id.btnurun:frm2();break;
            case R.id.btn_kalori:kalorihesapla();break;
        }
    }
    public double virgul(double sayi)
    {
        int sayi2=(int)(sayi*100);
        sayi=sayi2/100.0;
        return sayi;
    }
    public void kalorihesapla()
    {
        if(kontrolet())
        {
            double[] erkek= {66,6.8,13.7,5};
            double[] kadin= {655,4.7,9.6,1.8};
            double sonuc=0.0;
            double[] oranlar=kadin;
            double[] degerler=new double[4];
            degerler[0]=1;
            for(int i=0;i<jtext.length;i++)
                degerler[i+1]=Double.parseDouble(jtext[i].getText()+"");

            if(cins.getSelectedItemPosition()==0)//jrd radiobuuton secilimi değilmi
                oranlar=erkek;
                sonuc=(oranlar[0]*degerler[0]+oranlar[1]*degerler[1]+oranlar[2]*degerler[2])-(oranlar[3]*degerler[3]);
                sonuc=virgul(sonuc);
            topkalori.setText("Gün Kalori="+sonuc);
        }else{

            Toast.makeText(contex, "Bilgileri doğru giriniz!!!!", Toast.LENGTH_LONG).show();
        }

    }
int secileni;
    @Override
    public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
           secileni = i;
           jtext_gun = new EditText(this);
           gunlist = new ArrayList<String>();
           for (int a = 0; a < cadp.getCount(); a++)
               gunlist.add(cadp.getItem(a));
           gunadp = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, gunlist);
           gunurun = new Spinner(this);
           gunurun.setAdapter(gunadp);
           gunurun_id = new ArrayList<Integer>();
           for (int a = 0; a < urunid.size(); a++)
               gunurun_id.add(urunid.get(a));
           layout = new LinearLayout(this);
           layout.setOrientation(LinearLayout.VERTICAL);
           dialog = new AlertDialog.Builder(this);
           layout.addView(gunurun);
           layout.addView(jtext_gun);
           dialog.setView(layout);
           Kalori k = liste.get(i);
           jtext_gun.setText(k.miktar + "");
           dialog.setCancelable(true);
           dialog.setTitle("Sil veya Düzenle");
           dialog.setPositiveButton("Sil", new DialogInterface.OnClickListener() {
               @Override
               public void onClick(DialogInterface dialogInterface, int i) {
                   sil(id.get(secileni));
               }
           });
           dialog.setNeutralButton("Düzenle", new DialogInterface.OnClickListener() {
               @Override
               public void onClick(DialogInterface dialogInterface, int i) {

                   if (secileni > -1 && jtext_gun.getText().length() > 0) {
                       try {
                           double miktar = Double.parseDouble(jtext_gun.getText() + "");
                           int urun_id = gunurun_id.get(gunurun.getSelectedItemPosition());
                           duzenle(id.get(secileni), miktar, urun_id);
                       } catch (Exception ex) {
                           Toast.makeText(contex, "Bilgileri doğru giriniz catch!!!!", Toast.LENGTH_LONG).show();
                       }

                   } else
                       Toast.makeText(contex, "Bilgileri doğru giriniz!!!!", Toast.LENGTH_LONG).show();
               }
           });
           dialog.create().show();
       }
}
package com.example.ali.kalorihesaplama;

import android.app.Activity;
import android.content.ContentValues;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.graphics.Color;
import android.os.Bundle;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.text.InputType;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.Spinner;
import android.widget.Toast;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Executors;
import java.util.zip.Inflater;

import list.URUN;
import list.urunadepter;
import veritabani.DB;

public class Main3Activity extends AppCompatActivity implements View.OnClickListener {
    DB vt;
    SQLiteDatabase db;
    ListView liste;
    urunadepter adp;
    List<URUN> list;
    ArrayList<Integer> id;
    Button btn;
    EditText urun,kalori;
    AlertDialog.Builder dialog;
    Context contex=this;
    int secilenid;
    URUN u;
    LinearLayout layout;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main3);
        urun=(EditText)findViewById(R.id.turun);
        kalori=(EditText)findViewById(R.id.tkalori);
        btn=(Button)findViewById(R.id.btninsert);
        btn.setOnClickListener(this);
        layout=new LinearLayout(this);
        id=new ArrayList<Integer>();
        vt= new DB(this);
        liste=(ListView)findViewById(R.id.lurun);
        list=new ArrayList<URUN>();
        adp=new urunadepter(this,list);
        liste.setAdapter(adp);
        datagetir();
        final EditText gunurun=new EditText(this);
        final EditText gunkalori=new EditText(this);
        layout.setOrientation(LinearLayout.VERTICAL);
        layout.addView(gunurun);
        layout.addView(gunkalori);
        liste.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
                u=list.get(i);
                secilenid=id.get(i);
                gunurun.setText(u.urunad);
                gunkalori.setText(u.kalori+"");
                dialog=new AlertDialog.Builder(contex);
                dialog.setView(layout);
                dialog.setTitle("Sil veya Düzenle");
                dialog.setCancelable(true);
                dialog.setPositiveButton("Sil", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialogInterface, int i) { sil(secilenid); }});
                dialog.setNeutralButton("Düzenle", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialogInterface, int i) {
                        if(gunurun.getText().length()>0&&gunkalori.getText().length()>0){
                            double kal=Double.parseDouble(gunkalori.getText()+"");
                            guncelle(secilenid,gunurun.getText()+"",kal);
                        }
                    }
                });
                dialog.create().show();
            }
        });

    }
    public void baglan()
    {
        db=vt.getWritableDatabase();
    }
    @Override
    public void onClick(View view) {
        try {
            baglan();
            if (urun.getText().length() > 0 && kalori.getText().length() > 0)
            {
                double kal=Double.parseDouble(kalori.getText()+"");
                ContentValues par=new ContentValues();
                par.put("Urunad",urun.getText()+"");
                par.put("Kalori",kal);
                long durum= db.insertOrThrow("Urun",null,par);
                urun.setText("");
                kalori.setText("");
                vt.kapat();
                datagetir();
                MainActivity.spinnerdoldur(this);

            }
        }catch(Exception ex){
            Toast.makeText(this,ex.getMessage(),Toast.LENGTH_LONG).show();
        }
    }

    public void sil(int id)
    {
        try {
            baglan();
            db.delete("Urun","id=?",new String[]{id+""});
            datagetir();
        }
        catch(Exception ex){
            Toast.makeText(this,ex.getMessage(),Toast.LENGTH_LONG).show();
        }

    }
    public void guncelle(int id,String ad,double kalori)
    {
        try {
            baglan();
            ContentValues par=new ContentValues();
            par.put("Urunad",ad);
            par.put("Kalori",kalori);
            db.update("Urun",par,"id=?",new String[]{id+""});
            vt.kapat();
            datagetir();
        }catch(Exception ex){
            Toast.makeText(this,ex.getMessage(),Toast.LENGTH_LONG).show();
        }
    }
    public void datagetir()
    {
        try {
            baglan();
            String[] col={"id","Urunad","Kalori"};
            Cursor c=db.query("Urun",col,null,null,null,null,null);
            list.clear();
            adp.notifyDataSetChanged();
            id.clear();
            c.moveToPosition(-1);
            while(c.moveToNext())
            {  URUN d=new URUN();
                d.urunad=c.getString(1);
                d.kalori=c.getDouble(2);
                id.add(c.getInt(0));
                list.add(d);
            }
            c.close();
            vt.kapat();
        }catch(Exception ex){
            Toast.makeText(this,ex.getMessage(),Toast.LENGTH_LONG).show();
        }
    }
}

DataBaseKullanm Tamamını indir

package com.example.ali.databasekullanm;

import android.app.AlertDialog;
import android.content.ContentValues;
import android.content.Context;
import android.content.DialogInterface;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.Toast;

import java.util.ArrayList;
import java.util.List;

import adepter.myadepter;
import kisi.Kisi;
import veritabani.vt;

public class MainActivity extends AppCompatActivity implements View.OnClickListener{
    ListView lv;
    EditText[] et,et_gun;
    int[] id={R.id.ad,R.id.soyad,R.id.yas};
    myadepter adp;
    List<Kisi> liste;
    ArrayList<Integer> idliste;
    Button btn;
    vt vtys;
    SQLiteDatabase db;
    AlertDialog.Builder dialog;
    LinearLayout layout;
    int secilenid;
    Context context;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        context=this;
        et=new EditText[id.length];
        vtys=new vt(this);
        lv=(ListView)findViewById(R.id.list);
        liste=new ArrayList<Kisi>();
        adp=new myadepter(this,liste);
        lv.setAdapter(adp);
        for(int i=0;i<id.length;i++)
            et[i]=(EditText)findViewById(id[i]);
        btn=(Button)findViewById(R.id.btnekle);
        btn.setOnClickListener(this);
        idliste=new ArrayList<Integer>();
        datagetir();
        lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
                secilenid=i;
                layout=new LinearLayout(context);
                layout.setOrientation(LinearLayout.VERTICAL);
                dialog=new AlertDialog.Builder(context);
                dialog.setTitle("Düzenle veya Sil");
                dialog.setCancelable(true);
                et_gun=new EditText[et.length];
                for(int a=0;a<id.length;a++) {
                    et_gun[a] = new EditText(context);
                    layout.addView(et_gun[a]);
                }
                Kisi k=liste.get(secilenid);
                et_gun[0].setText(k.ad);
                et_gun[1].setText(k.soyad);
                et_gun[2].setText(k.yas+"");
                dialog.setView(layout);
                dialog.setPositiveButton("Düzenle", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialogInterface, int i) {

                        if(kontrol(et_gun))
                          {   int id=idliste.get(secilenid);
                              try {

                                  baglan();
                                  int yas=Integer.parseInt(et_gun[2].getText()+"");
                                  ContentValues par=new ContentValues();
                                  par.put("ad",et_gun[0].getText()+"");
                                  par.put("soyad",et_gun[1].getText()+"");
                                  par.put("yas",yas);
                                  db.update("Kisi",par,"id=?",new String[]{id+""});
                                  db.close();
                                  datagetir();
                              }catch (Exception ex)
                              {
                                  Toast.makeText(context,ex.getMessage(),Toast.LENGTH_LONG).show();
                              }

                          }
                    }
                });
                dialog.setNegativeButton("Sil", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    int id=idliste.get(secilenid);
                    try {
                        baglan();
                        int yas=Integer.parseInt(et_gun[2].getText()+"");
                        db.delete("Kisi","id=?",new String[]{id+""});
                        db.close();
                        datagetir();
                    }catch (Exception ex) {
                        Toast.makeText(context, ex.getMessage(), Toast.LENGTH_LONG).show();
                    }
                }
            });
                dialog.create().show();
                }

        });
    }
public void baglan()
{
    try {
        db=vtys.getWritableDatabase();
    }
    catch (Exception ex)
    {
        Toast.makeText(getApplicationContext(),ex.getMessage(),Toast.LENGTH_LONG).show();
    }

}
public boolean kontrol(EditText[] jtext)
{
    int sayac=0;
 for(int i=0;i<jtext.length;i++)
     if(jtext[i].getText().length()>0)
         sayac++;
    if(sayac==jtext.length)
        return  true;
 return false;
}
    @Override
    public void onClick(View view) {
        try {

            baglan();
            int yas=Integer.parseInt(et[2].getText()+"");
            if(kontrol(et))
            {
                ContentValues par=new ContentValues();
                par.put("ad",et[0].getText()+"");
                par.put("soyad",et[1].getText()+"");
                par.put("yas",yas);
              db.insertOrThrow("Kisi",null,par);
              db.close();
             datagetir();
            }
        }
        catch (Exception ex)
        {
            Toast.makeText(getApplicationContext(),ex.getMessage(),Toast.LENGTH_LONG).show();
        }
    }
 public void datagetir(){
        try {
            baglan();
            Cursor c=db.query("Kisi",new String[]{"id","ad","soyad","yas"},null,null,null,null,null);
            liste.clear();
            idliste.clear();
            adp.notifyDataSetChanged();//liste değisiklik oldupu için adepteri güncelliyoruz
            c.moveToPosition(-1);//işaretcinin(Cursor) pozisyonu ayalıyoruz tablonun ilk satırından baslaması için
            while(c.moveToNext())//ileri diyoruz boylece Cursor tablonun ilk satırına geciyor
            {
                Kisi k=new Kisi();
                k.ad=c.getString(1);
                k.soyad=c.getString(2);
                k.yas=c.getInt(3);
                liste.add(k);//liste Kisi tipinde item aldığı için Kisi sınıfından nesne turetip degiskenlerine atıp nesneyi attık
                idliste.add(c.getInt(0));
            }
            db.close();
            c.close();
        }
        catch (Exception ex)
        {
           Toast.makeText(getApplicationContext(),ex.getMessage(),Toast.LENGTH_LONG).show();
        }

 }
}
package adepter;

import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.example.ali.databasekullanm.R;

import java.util.List;

import kisi.Kisi;

public class myadepter extends BaseAdapter {
    List<Kisi> liste;
    LayoutInflater layout;
    public myadepter(Activity a,List<Kisi> liste){
        this.liste=liste;
        layout=(LayoutInflater)a.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    }
    @Override
    public int getCount() {
        return liste.size();
    }

    @Override
    public Object getItem(int i) {
        return liste.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        View v=layout.inflate(R.layout.colum,null);
        TextView t1=(TextView)v.findViewById(R.id.ad);
        TextView t2=(TextView)v.findViewById(R.id.soyad);
        TextView t3=(TextView)v.findViewById(R.id.yas);
        Kisi k=liste.get(i);
       t1.setText(k.ad);
       t2.setText(k.soyad);
       t3.setText(""+k.yas);
        return v;
    }
}<span id="mce_marker" data-mce-type="bookmark" data-mce-fragment="1">​</span>
 package kisi;

public class Kisi {
public String ad;
public String soyad;
public int yas;
}
<span id="mce_marker" data-mce-type="bookmark" data-mce-fragment="1">​</span>

 

 

  <RelativeLayout
        android:layout_width="375dp"
        android:layout_height="503dp">
<TableLayout
    android:layout_width="match_parent"
   android:layout_marginTop="10dp"
    android:layout_height="450dp"
    android:layout_marginLeft="10dp">
    <TableRow
        android:layout_width="match_parent"
        android:layout_height="100dp">

<TableRow
    android:layout_width="190dp"
    android:layout_height="300dp">

    <ListView
        android:id="@+id/llist"
        android:layout_width="170dp"
        android:layout_height="250dp"
        android:layout_marginLeft="10dp"
        android:layout_marginTop="10dp"></ListView>
</TableRow>
        <Spinner
            android:id="@+id/slist"
            android:layout_width="100dp"
            android:layout_height="50dp"
            ></Spinner>

    </TableRow>
    <TableRow
        android:layout_width="match_parent"
        android:layout_height="100dp">
        <EditText
            android:id="@+id/tad"
            android:layout_width="100dp"
            android:layout_height="45dp"/>

    </TableRow>
    <TableRow
        android:layout_width="match_parent"
        android:layout_height="100dp">
        <Button
            android:id="@+id/btn_ekle"
            android:layout_width="100dp"
            android:layout_height="45dp"
            android:text="Ekle"
            />
        <Button
            android:id="@+id/btn_sil"
            android:layout_width="100dp"
            android:layout_height="45dp"
            android:text="Sil"
             />
        <Button
            android:id="@+id/newactivity"
            android:layout_width="120dp"
            android:layout_height="45dp"
            android:text="NEW FORM"
            />

    </TableRow>
</TableLayout>
    </RelativeLayout>
package com.example.ali.ilkuygulama;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.*;

import java.util.ArrayList;

public class MainActivity  extends AppCompatActivity  implements  View.OnClickListener{
    EditText tad;
    Button btnekle,btnsil,btn_frm;
    ListView llist;
    Spinner slist;
    ArrayList<String>[] liste;
    ArrayAdapter<String>[] adp;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        tad=(EditText)findViewById(R.id.tad);
        btnekle=(Button)findViewById(R.id.btn_ekle);
        btnekle.setOnClickListener(this);
        btnsil=(Button)findViewById(R.id.btn_sil);
        btnsil.setOnClickListener(this);
        btn_frm=(Button)findViewById(R.id.newactivity);
        btn_frm.setOnClickListener(this);
        liste=new ArrayList[]{new ArrayList(),new ArrayList()};
        adp=new ArrayAdapter[]{new ArrayAdapter(this,android.R.layout.simple_list_item_1,liste[0]),new ArrayAdapter(this,android.R.layout.simple_spinner_item,liste[1])};
       //Yukarı da listeleri adeptere baglıyorum
        llist=(ListView)findViewById(R.id.llist);
        slist=(Spinner)findViewById(R.id.slist);
        llist.setAdapter(adp[0]);//Componentlere adepterleri bağlıyorum yani set ediyorum
        slist.setAdapter(adp[1]);

    }

    @Override
    public void onClick(View view) {
        switch (view.getId()){//Butonların id'sine göre
            case R.id.btn_ekle:ekle();break;
            case R.id.btn_sil:sil();break;
            case R.id.newactivity:newfrm();break;
        }
    }
public void ekle(){
    if(tad.getText().length()>0) {
        adp[0].add(tad.getText()+"");//item'leri Adepter ile ekliyorum
        adp[1].add(tad.getText()+"");
        tad.setText("");

    }else
        Toast.makeText(getApplicationContext(),"Bilgileri Doğru giriniz!!", Toast.LENGTH_LONG).show();
    //Mesaj verme
}
public void sil(){
      int secilen=slist.getSelectedItemPosition();//Spinner den sectiğim item' in index numarası
    if(secilen>-1)
        liste[1].remove(secilen);//Array den siliyorum
        adp[1].notifyDataSetChanged();//Adepter'i güncelliyorum

    }
public void newfrm(){
 //  Intent frm=new Intent(this,Main2Activity.class);
  // startActivity(frm);

    //Intent nesnesi ile suan için işim olmadıgı için 2.forma böyle gecis
    startActivity(new Intent(this,Main2Activity.class));
}
}
<span id="mce_marker" data-mce-type="bookmark" data-mce-fragment="1">​</span>

 

//1.Yöntem
package com.example.ali.ilkuygulama;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.*;
public class MainActivity  extends AppCompatActivity  implements  View.OnClickListener{
    TextView tgos;              //Yukarıdaki View.OnClickListener interface yi implemente ederek ve Onclick fonksiyonunu
    EditText tad;               //ezerek(Override) ederek tetikleme yöntemi
    Button akt,btnsil;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        tgos=(TextView)findViewById(R.id.lblad);//xml deki Textview'in id'si ile buradaki Texview'e bağlıyoruz
        tad=(EditText)findViewById(R.id.tad);//Aynı şekilde xmlde ki butonları burdaki butonlara bağlıyoruz
        akt=(Button)findViewById(R.id.btn);
        akt.setOnClickListener(this);
        btnsil=(Button)findViewById(R.id.btn_sil);
        btnsil.setOnClickListener(this);
        }

    @Override
    public void onClick(View view) {
        switch (view.getId()){//Butonların id'sine göre
            case R.id.btn:aktar();break;
            case R.id.btn_sil:sil();break;
        }
    }
public void aktar(){
    if(tad.getText().length()>0) {
        tgos.setText(tad.getText());
        tad.setText("");

    }else
        Toast.makeText(getApplicationContext(),"Bilgileri Doğru giriniz!!", Toast.LENGTH_LONG).show();
    //Mesaj verme
}
public void sil(){
    tgos.setText("TextView");
    }
}


<RelativeLayout
        android:layout_width="375dp"
        android:layout_height="503dp">
<TableLayout
    android:layout_width="match_parent"
   android:layout_marginTop="10dp"
    android:layout_height="200dp"
    android:layout_marginLeft="10dp">
    <TableRow
        android:layout_width="match_parent"
        android:layout_height="100dp">
        <TextView
            android:id="@+id/lblad"
            android:layout_width="100dp"
            android:layout_height="30dp"
            android:text="TextView"/>

    </TableRow>
    <TableRow
        android:layout_width="match_parent"
        android:layout_height="100dp">
        <EditText
            android:id="@+id/tad"
            android:layout_width="100dp"
            android:layout_height="45dp"/>

    </TableRow>
    <TableRow
        android:layout_width="match_parent"
        android:layout_height="100dp">
        <Button
            android:id="@+id/btn"
            android:layout_width="100dp"
            android:layout_height="45dp"
            android:text="Aktar"/>
        <Button
            android:id="@+id/btn_sil"
            android:layout_width="100dp"
            android:layout_height="45dp"
            android:text="Sil"/>
    </TableRow>
</TableLayout>
    </RelativeLayout>
//2.Yöntem
package com.example.ali.ilkuygulama;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.*;
public class MainActivity  extends AppCompatActivity  {
    TextView tgos;
    EditText tad;
    Button akt,btnsil;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        tgos=(TextView)findViewById(R.id.lblad);//xml deki Textview'in id'si ile buradaki Texview'e bağlıyoruz
        tad=(EditText)findViewById(R.id.tad);//Aynı şekilde xmlde ki butonları burdaki butonlara bağlıyoruz
        akt=(Button)findViewById(R.id.btn);
        akt.setOnClickListener(new View.OnClickListener() { //inner class yöntemiyle buton tetikleme fonksiyonu
            @Override
            public void onClick(View view) {
                if(tad.getText().length()>0) {
                    tgos.setText(tad.getText());
                    tad.setText("");

                }else
                    Toast.makeText(getApplicationContext(),"Bilgileri Doğru giriniz!!", Toast.LENGTH_LONG).show();
                    //Mesaj verme
            }
        });
        btnsil=(Button)findViewById(R.id.btn_sil);
        btnsil.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                tgos.setText("TextView");
            }
        });

        }
    }
 <RelativeLayout
        android:layout_width="375dp"
        android:layout_height="503dp">
<TableLayout
    android:layout_width="match_parent"
   android:layout_marginTop="10dp"
    android:layout_height="200dp"
    android:layout_marginLeft="10dp">
    <TableRow
        android:layout_width="match_parent"
        android:layout_height="100dp">
        <TextView
            android:id="@+id/lblad"
            android:layout_width="100dp"
            android:layout_height="30dp"
            android:text="TextView"/>

    </TableRow>
    <TableRow
        android:layout_width="match_parent"
        android:layout_height="100dp">
        <EditText
            android:id="@+id/tad"
            android:layout_width="100dp"
            android:layout_height="45dp"/>

    </TableRow>
    <TableRow
        android:layout_width="match_parent"
        android:layout_height="100dp">
        <Button
            android:id="@+id/btn"
            android:layout_width="100dp"
            android:layout_height="45dp"
            android:text="Aktar"
            android:onClick="aktar"
            tools:ignore="OnClick"/>
        <Button
            android:id="@+id/btn_sil"
            android:layout_width="100dp"
            android:layout_height="45dp"
            android:text="Sil"
            android:onClick="sil"
            tools:ignore="OnClick" />

    </TableRow>

</TableLayout>
    </RelativeLayout><span id="mce_marker" data-mce-type="bookmark" data-mce-fragment="1">​</span>
//3.Yöntem ise xml'de onclick fonksiyonlarını belirtme ve MainActivity sınıfında fonksiyonlarını olusturma 
package com.example.ali.ilkuygulama;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.*;
public class MainActivity  extends AppCompatActivity {
    TextView tgos;
    EditText tad;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        tgos=(TextView)findViewById(R.id.lblad);//xml deki Textview'in id'si ile buradaki Texview'e bağlıyoruz
        tad=(EditText)findViewById(R.id.tad);
        }

public void aktar(View v){
    if(tad.getText().length()>0) {
        tgos.setText(tad.getText());
        tad.setText("");

    }else
        Toast.makeText(getApplicationContext(),"Bilgileri Doğru giriniz!!", Toast.LENGTH_LONG).show();
    //Mesaj verme
}
public void sil(View v){
    tgos.setText("TextView");
    }
}
<span id="mce_marker" data-mce-type="bookmark" data-mce-fragment="1">​</span>