NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io


Listeleme

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_margin="16dp"
tools:context=".ListelemeActivity">

<TextView
android:id="@+id/siralaBtn"
android:layout_margin="16dp"
android:text="Sýrala"
android:background="#9726"
android:textStyle="bold"
android:layout_width="match_parent"
android:layout_height="30dp" />

<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">

<Button
android:id="@+id/isimSiralaBtn"
android:layout_margin="8dp"
android:text="ÝSÝM"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<Button
android:id="@+id/telefonSiralaBtn"
android:layout_margin="8dp"
android:text="TELEFON"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<Button
android:id="@+id/mailSiralaBtn"
android:layout_margin="8dp"
android:text="MAÝL"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>

<ListView
android:id="@+id/listViewRehber"
android:layout_margin="16dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"></ListView>
</LinearLayout>

---------------------------------------------------------------------------------------------------

package com.example.volka.rehber;

import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ListView;

import java.util.ArrayList;

public class ListelemeActivity extends AppCompatActivity implements View.OnClickListener {
Button isimBtn, telefonBtn, mailBtn;
ListView rehber;
VeriTabani vt;
String ad, mail, tel;
String nameStr, phoneStr, mailStr, numberStr;
int id1;
ArrayList<String> txt = new ArrayList<String>(); //listview listelemek için

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_listeleme);
rehber = findViewById(R.id.listViewRehber);

//butonlara toplu týklanma
isimBtn = findViewById(R.id.isimSiralaBtn);
isimBtn.setOnClickListener(this);

telefonBtn = findViewById(R.id.telefonSiralaBtn);
telefonBtn.setOnClickListener(this);

mailBtn = findViewById(R.id.mailSiralaBtn);
mailBtn.setOnClickListener(this);

//veritabanýný çaðrýyoruz
vt = new VeriTabani(this);


}

@Override
public void onClick(View view) {
//vt yi açýyoruz
SQLiteDatabase db = vt.getWritableDatabase();

String orderBy = null; //sýralamak için, mutlaka null atalamlýyýz yoksa çalýþmaz

//vt yi konumlandýrmak için cursor
Cursor cursor = null;

switch (view.getId()) {
case R.id.isimSiralaBtn:
orderBy = "ISIM";
break; //vt deki isimlere göre
case R.id.telefonSiralaBtn:
orderBy = "TEL_NO";
break;
case R.id.mailSiralaBtn:
orderBy = "EMAIL";
break;
}
cursor = db.query("KAYIT", null, null, null, null, null, orderBy);

//okudukça sýrakine hareket et
while (cursor.moveToNext()) {

ad = cursor.getString(cursor.getColumnIndex("ISIM"));
id1 = cursor.getInt(cursor.getColumnIndex("ID")); //int tipinde oldç dn int olarak taýmlandý
tel = cursor.getString(cursor.getColumnIndex("TEL_NO"));
mail = cursor.getString(cursor.getColumnIndex("EMAIL"));

txt.add(id1 + "t" + ad + "t" + tel + "t" + mail); // arrayýn adý txt : t nin amacý tablo görünümü oluþturmak

}
//vt yi ve cursor ý kapatýyoruz
cursor.close();
db.close();

//listview adapter kullanmak zorunda- string array adapter oluþturuyoruz


ArrayAdapter<String> veriAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, android.R.id.text1, txt);
rehber.setAdapter(veriAdapter);

//týklanma olayý verdik çünkü ilgili satýra týklanýldýýnda result atvity e göndere
rehber.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {

//verileri parçalara ayýrarak, veri dizisine aktarýyoruz
String[] veri = txt.get(i).split("t");

Intent sendData = new Intent(getApplicationContext(), ResultActivity.class);
sendData.putExtra("ID", veri[0]);
sendData.putExtra("ISIM", veri[1]);
sendData.putExtra("TEL_NO", veri[2]);
sendData.putExtra("EMAIL", veri[3]);
startActivity(sendData);
}
});
}

}
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.