Last active
April 22, 2020 17:04
-
-
Save 999Phoenix999/9621851 to your computer and use it in GitHub Desktop.
Codes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.tabdeneme; | |
import android.os.Bundle; | |
import android.app.TabActivity; | |
import android.content.ContentValues; | |
import android.content.Intent; | |
import android.content.res.Resources; | |
import android.database.sqlite.SQLiteDatabase; | |
import android.graphics.Color; | |
import android.view.View; | |
import android.view.View.OnClickListener; | |
import android.widget.Button; | |
import android.widget.EditText; | |
import android.widget.FrameLayout; | |
import android.widget.LinearLayout; | |
import android.widget.TabHost; | |
import android.widget.TabWidget; | |
import android.widget.TextView; | |
import android.widget.TabHost.TabSpec; | |
@SuppressWarnings("deprecation") | |
public class MainActivity extends TabActivity{ | |
Button btn; | |
EditText ad; | |
EditText soyad; | |
private veritabani v1; | |
@Override | |
public void onCreate(Bundle savedInstanceState) | |
{ | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); | |
v1=new veritabani(this); | |
btn=(Button)findViewById(R.id.button1); | |
ad=(EditText)findViewById(R.id.editText1); | |
soyad=(EditText)findViewById(R.id.editText2); | |
Resources ressources = getResources(); | |
TabHost tabHost = getTabHost(); | |
//Sorgu Penceresi | |
Intent intentSorgu = new Intent().setClass(this, Tab1Activity.class); | |
TabSpec tab1 = tabHost.newTabSpec("First Tab").setIndicator("", ressources.getDrawable(R.drawable.icon_android_config)).setContent(new Intent(this,Tab1Activity.class)); | |
//Geçmiş Penceresi | |
Intent intentGecmis = new Intent().setClass(this, Tab2Activity.class); | |
TabSpec tab2 = tabHost.newTabSpec("Second Tab").setIndicator("",ressources.getDrawable(R.drawable.icon_apple_config)).setContent(new Intent(this,Tab2Activity.class)); | |
TabWidget tabwidget = (TabWidget)findViewById(android.R.id.tabs); | |
tabwidget.setBackgroundColor(Color.RED); | |
tabHost.addTab(tab1); | |
tabHost.addTab(tab2); | |
tabHost.setCurrentTab(0); | |
btn.setOnClickListener(new View.OnClickListener() { | |
public void onClick(View v) | |
{ | |
ekleme(ad.getText().toString(),soyad.getText().toString()); | |
v1.close(); | |
} | |
}); | |
} | |
private void ekleme(String ad,String soyad) | |
{ | |
SQLiteDatabase db=v1.getWritableDatabase(); | |
ContentValues cv1 = new ContentValues(); | |
cv1.put("ad",ad); | |
cv1.put("soyad", soyad); | |
db.insertOrThrow("bilgiler", null, cv1); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.tabdeneme; | |
import android.app.Activity; | |
import android.database.Cursor; | |
import android.database.sqlite.SQLiteDatabase; | |
import android.os.Bundle; | |
import android.view.View; | |
import android.widget.Button; | |
import android.widget.TextView; | |
public class Tab2Activity extends Activity | |
{ | |
TextView ad1; | |
TextView ad2; | |
Button btn2; | |
private String[] sutunlar={"ad","soyad"}; | |
private veritabani obj; | |
public void onCreate(Bundle savedInstanceState) | |
{ | |
super.onCreate(savedInstanceState); | |
obj = new veritabani(this); | |
ad1=(TextView)findViewById(R.id.textView1); | |
ad2=(TextView)findViewById(R.id.textView2); | |
btn2=(Button)findViewById(R.id.button2); | |
btn2.setOnClickListener(new View.OnClickListener() { | |
@Override | |
public void onClick(View v) { | |
bilgilerigoster(); | |
} | |
}); | |
} | |
public void bilgilerigoster() | |
{ | |
SQLiteDatabase db=obj.getReadableDatabase(); | |
Cursor okunanlar = db.query("bilgiler", sutunlar, null, null, null, null, null); | |
while(okunanlar.moveToNext()) | |
{ | |
String add = okunanlar.getString(okunanlar.getColumnIndex("ad")); | |
String soyadd = okunanlar.getString(okunanlar.getColumnIndex("soyad")); | |
ad1.setText(add); | |
ad2.setText(soyadd); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.tabdeneme; | |
import android.content.Context; | |
import android.database.sqlite.SQLiteDatabase; | |
import android.database.sqlite.SQLiteOpenHelper; | |
public class veritabani extends SQLiteOpenHelper | |
{ | |
private static final String VERİTABANİ_ADİ="kayitlar"; | |
private static final int SURUM=1; | |
public veritabani(Context c) | |
{ | |
super(c,VERİTABANİ_ADİ,null,SURUM); | |
} | |
@Override | |
public void onCreate(SQLiteDatabase db) | |
{ | |
db.execSQL("CREATE TABLE bilgiler(ad TEXT,soyad TEXT);"); | |
} | |
@Override | |
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) | |
{ | |
db.execSQL("DROP TABLE IF EXIST bilgiler"); | |
onCreate(db); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment