• II bob bo’yicha xulosalar
  • FOYDALANILGAN ADABIYOTLAR RO’YXATI 1. Karimov I.A. Vatan Sajdagoh kabi muqaddasdir. Asarlar
  • ILOVALAR MainActivity.java
  • ToDoDatabase.java
  • EditActivity.java
  • List_row.xml
  • Edit_main.xml
  • Buxoro davlat universiteti




    Download 197.95 Kb.
    bet3/3
    Sana21.03.2017
    Hajmi197.95 Kb.
    1   2   3

    II.2. Android OT da dars jadvali dasturini yaratish.

    Dars jadvali dasturini yaratishda bizga quyidagi bilimlar kerak bo’ladi:

    1. Androidda oynalar bilan ishlash (Intentlar)

    2. Androidda ma’lumotlar ombori bilan ishlash (SQLite)

    3. Androidda formalar bilan ishlash (View)

    4. Androidda tizim resurslari bilan ishlash (Time, Date)

    Intentlar bu Android dasturidagi oynalarni boshqaruvchi maxsus obyekt bo’lib, bir oynadan ikkinchi oynani chaqirish, oyna holatlarini boshqarish, oynani yopish, oynani o’chirib tashlash kabi amallarni bajaradi.

    Androidda tuziladigan dasturlarning aksariyati ko’p oynali dasturlar hisoblanadi. Masalan, biror bir foydali dastur yaratganimizdan so’ng, foydalanuvchi dasturning muallifi haqida ma’lumot olmoqchi bo’lsa, “Dastur haqida” tugmasini bosganda dastur haqida to’liq ma’lumot beruvchi oynaga tushib qoladi. Bu veb sahifalarda gipermatn orqali birinchisidan ikkinchisiga o’tishga juda o’xshaydi. Oddiy misol orqali bir oynadan ikkinchisiga o’tilishi quyidagicha bajariladi.

    Eclipseda yangi proyekt yaratib, unda yangi XML layout yaratamiz va about.xml deb nomlaymiz. Bu faylni quyidagi XML kod bilan to’ldiramiz.



    xmlns:android="http://schemas.android.com/apk/res/android"

    android:layout_width="fill_parent"

    android:layout_height="fill_parent"

    android:padding="10dip">

    android:id="@ id/about_content"

    android:layout_width="wrap_content"

    android:layout_height="wrap_content"

    android:text="@string/about_text" />

    Ma’lumot oldindan e’lon qilingan o’zgarmaslarda olinadi. Shuning uchun bu o’zgarmaslarni res/values/strings.xml faylida e’lon qilib qo’yamiz.



    Dars jadvali dasturiga xush kelibsiz

    Endi oyna sarlavhasi uchun o’zgarmas e’lon qilinadi.

    Dastur haqida

    So’ngra dastur kodlarini yozish uchun yangi Class yaratiladi va uni AboutActivity.java deb nomlaymiz. Ichida quyidagi kod yoziladi.

    package dars.jadvali.helloworld;

    import android.app.Activity;

    import android.os.Bundle;

    public class AboutActivity extends Activity

    {

    @Override



    protected void onCreate(Bundle savedInstanceState)

    {

    super.onCreate(savedInstanceState);



    setContentView(R.layout.about);

    }

    }



    Bu klassda eng asosiy metod bu onCreate() va setContentView() metodlaridir. Chunki aynan ular klass yaratilayotgan vaqtda kerakli ma’lumotni ko’rsatish uchun xizmat qiladi. Endi Helloworld.java klassi orqali undagi tugma bosilganda AboutActivity.java ga o’tish kodlari yoziladi. Bunda bizlarga Intent klassi qo’l keladi.

    import android.content.Intent;

    Tugma uchun Click metodini yozamiz:

    public void onClick(View v)

    {

    Intent intent = new Intent(HelloWorld.this, AboutActivity.class);



    startActivity(intent);

    }

    Yangi oyna yuklanishi uchun Intent klassida AboutActivity klassini ko’rsatib qo’yish kerak bo’ladi. Undan so’ng startActivity() metodi chaqiriladi. Undan oldin esa yangi Activity klassni AndroidManifest.xml ga kiritib qo’yish kerak bo’ladi.



    android:label="@string/about_title">



    Emulyatorni ishga tushirib natijani ko’rishimiz mumkin.



    2.2.1-rasm. Dasturni ochilishi


    Android ma’lumotlar bazasi bilan ishlash mexanizmi strukturali informatsiyalarni qayta ishlash va saqlash imkoniyati mavjud. Istalgan ilova o’ziga tegishli ma’lumotlar bazasini yaratishi va ular ustida to’liq nazorat qila oladi. Android SQLite kutubxonasidan foydalanib, MBBT ma’lumotlarini o’zidan ko’rsatib, quyidagi o’ziga xos xususiyatlarga ega: ko’lami kengligi (open source), tranzaksiya va so’rovlarning standart tili, osonligi va bir xil darajaliligi.

    Kursorlar (Cursor) vaContentValues

    So’rovlar MBBTga Cursor tipining obyektlarini qaytaradi. Resurslar tejamkorligi uchun ma’lumotlar qabul qilanayotganda MBBTdan ularning qiymatlarini qaytarmaydi. Cursor yaratilayotganda esa dastlabki ma’lumotlarning to’plamiga yo’l beradi. Cursor obyektining metodlari har xil navigatsiya imkoniyatlarini taqdim etadi:

    -moveToFirst;

    -moveToNext;

    -moveToPrevious;

    -getCount;

    -getColumnIndexOrThrow;

    -getColumnName;

    -getColumnNames;

    -moveToPosition;

    -getPosotion;

    MBBT jadvallariga ma’lumotlarni qo’shishda ContentValues sinfining obyektlari ishlatiladi. Har bir shunday obyekt jadvalda bir satr ma’lumotlarini o’z ichiga oladi.

    SQLite MBBT bilan ishlash

    Ilova yaratilishida MBBTdan foydalaniladi. Ko’p hodisalarda ORM (Object-Relationship Mapping) deb nomlanuvchi qulay instrumentalar ishlatiladi. Berilgan ma’lumotlarni obyektlarga bir yoki bir necha jadvallarga joylashtirish dasturlash tilida beriladi. Bundan tashqari ORM MBBT bilan birgalikda majburiyatlarni o’zi-ga olib, jadval strukturasini va konkertlikdan qochib eng muhim tomonlaridan foydalanishga harakat qiladi. Afsuski, hozirgi vaqtda ORM mobil platformasining kuchi chegaralanganligi bois androidda amaliyotda qo’llanilamaydi. Ilova ishlashi-da aql bilan yondashish MBBT bilan barcha o’zaro aloqalarni bir sinfda inkapsyu-latsiya qilishdir. Metodlar esa ilova qolgan komponentlarning kerakli xizmatlarini bajaradi.Yaxshi amaliyot MBBTdan o’zining ishiga olib, yordamchi sinfining yaratilishidan iborat. Mazkur sinf odatda ma’lumotlar bazasi bilan o’zaro birgalik-da inkapsyulatsiya bo’lib, obyektlarni qo’shish, o’chirish va o’zgartirishning o’ziga xos usullarni intuitive ravishda qat’iy mazmunini beradi. Ma’lumotlar bazasi adapteri shuningdek ma’lumotlar bazasini yaratish, yopish va ochish uchun metodlarni hammasini aniqlaydi va ma’lumotlar bazasiga so’rovlarni qayta ishlashga yuboradi. Adapterning ishlashi pastda berilgan.

    public class SampleDBAdapter {

    private static final String DATABASE_NAME = "SampleDatabase.db";

    private static final String DATABASE_TABLE = "SampleTable";

    private static final intDATABASE_VERSION = 1;

    // Indeks ustunining nomi

    public static final String KEY_ID = "_id";

    // Har bir ustun uchun nom berish

    public static final String KEY_NAME = "name";

    public static final intNAME_COLUMN = 1;

    // MBni yaratish uchun SQL- so’rov

    private static final String DATABASE_CREATE = "create table "

    DATABASE_TABLE " (" KEY_ID

    " integer primary key autoincrement, " KEY_NAME

    " textnotnull);";

    // MB obyektini saqlash uchun o’zgaruvchi

    private SQLiteDatabasedb;

    // Dastur konteksti

    private finalContextcontext;

    // MBni yangilash va ochish uchun yordamchi klass

    private myDbHelperdbHelper;

    // Konstruktor

    public SampleDBAdapter(Context _context) {

    context = _context;

    dbHelper = new myDbHelper(context, DATABASE_NAME, null,

    DATABASE_VERSION);

    }

    // Ma’lumotlar omboriga kirish



    public SampleDBAdapter open() throws SQLException {

    try {


    db = dbHelper.getWritableDatabase();

    }

    catch (SQLiteException e) {



    db = dbHelper.getReadableDatabase();

    }

    return this;



    }

    // Mbni yopish

    public void close() {

    db.close();

    }

    // Ma’lumotlarni qo’shish metodi, bu metod ma’lumot indeksini qaytaradi.



    public long insertEntry(SampleObject _SampleObject) {

    // Bu yerda o’z ichida kerakli ma’lumotlar joylashgan va MBga qo’yilishi //rejalashtirilgan ContentValues obyekti yasaladi

    returnindex;

    }

    // Indeksi bo’yicha ma’lumotni o’chirish



    public booleanremoveEntry(long _rowIndex) {

    returndb.delete(DATABASE_TABLE, KEY_ID "="

    _rowIndex, null) > 0;

    }

    // Barcha ma’lumotlarni olish metodi



    public Cursor getAllEntries() {

    returndb.query(DATABASE_TABLE, new String[] { KEY_ID, KEY_NAME },

    null, null, null, null, null);

    }

    // indeksi bo'yicha obyektning ekzemplyarni natija sifatida qaytaradi



    public SampleObjectgetEntry(long _rowIndex) {

    // kursorni qabul qiladi, MBdan kerakli ma’lumotlarni ko’rasatadi

    returnobjectInstance;

    }

    // Indeks bo’yicha obyektni o’zgartirish



    public boolean updateEntry(long _rowIndex, SampleObject _SampleObject) {

    // SampleObject asosida ContentValues obyektini yasash

    // jadvalda satrni yangilash uchun qo’llash

    return true; // Yangilansa true, aks holda false

    }

    // Mbni ochish va yangilash uchun yordamchi klass



    private static class myDbHelperextends SQLiteOpenHelper {

    public myDbHelper(Context context, String name,

    CursorFactory factory, intversion) {

    super(context, name, factory, version);

    }

    @Override



    public void onUpgrade(SQLiteDatabase _db, int_oldVersion,

    int_newVersion) {

    // ma’lumtlarni jurnalga qayd qilib borish

    Log.w("TaskDBAdapter", "Upgrading from version " _oldVersion

    " to " _newVersion

    ", which will destroy all old data");


    II bob bo’yicha xulosalar

    Ushbu bobda Eclipse hamda ADTni o’rnatish hamda sozlash jarayoni ko’rib chiqildi.

    Dasturning ko’pgina qismlarida tushunarli bo’lishi uchun kommentariylar qo’yib ketildi.

    Natija xatolik beradigan holatning oldi olindi va ekranda foydalanuvchi tushunadigan tilda xabar chiqaruvchi kod yozildi.

    Android operatsion tizimida ishlovchi dars jadvali yaratildi.
    XOTIMA
    Ushbu bitiruv malakaviy ishini bajarish jarayonida Android operatsion tizimining ishlash jarayonlari o’rganildi:

    – Android operatsion tizimi haqida nazariy ma’lumotlar o’rganildi;

    – ushbu OTga bog’liq bo’lgan barcha ma’lumotlar turli tillardan o’zbek tiliga tarjima qilindi;

    – Android OT haqidagi adabiyotlar ko’zdan kechirildi;

    – *.apk kengaytmali fayllar, ularning ishlash tartibi aniqlandi;

    – Google Market internet magazinidagi dasturlar o’rganildi;

    – Eclipse SDK va Android SDK dasturlash muhitlari haqida ma’lumotlar to’plandi;

    – ularning o’rnatilish, sozlash jarayonlari haqidagi ma’lumotlar tizimlashtirildi;

    – Android OT uchun dasturiy ta’minot yaratish bosqichlari o’rganildi;

    – Java tilida Android OT da ishlaydigan dars jadvali dasturi tuzildi;

    – Tuzilgan dastur va jamlangan bilimlar asosida foydalanuvchilarga kerakli tavsiyalar va xulosalar berildi.

    Yaratilgan dasturni har bir o’qituvchi, talaba yoki boshqa soha vakillari o’z ish sohalariga moslab dastur imkoniyatlarini kengaytirishlari va Google Play loyihasiga yuklab barchaga tavsiya etishlari mumkin.


    FOYDALANILGAN ADABIYOTLAR RO’YXATI
    1. Karimov I.A. Vatan Sajdagoh kabi muqaddasdir. Asarlar, 3-jild. ­–T.: O’zbekiston, 1996. –278 b.

    2. Karimov I.A. Xavfsizlik va barqaror taraqqiyot yo’lidan. Asarlar, 6-jild. –T.: O’zbekiston, 1998. –429 b.

    3. Barkamol avlod orzusi. –T. O’zbekiston milliy ensiklopediyasi, 2000.-246 b.

    Asar (arab. - iz, qodsiq) - 1) bi-ror narsadan qolgan yoki undan darak beruvchi belgi; nishon, iz; 2) Muhammad (sav) dan qolgan barcha sunnatlar; 3) olim, yozuvchi, rassom, bastakor va boshqa ijodining mahsuli.

    Ensiklopediya (yunon. ἐγκύκλιος παιδεία - barcha bilimlar doirasida taʼlim olish) yoki qomus ilmiy yoki ilmiy-ommabop nashrdir. Oʻzida barcha (universal ensiklopediya) yoki baʼzi (soha ensiklopediyasi) sohalar boʻyicha nazariy hamda amaliy bilimlarni saqlaydi.

    4. Dmitriy Volkov. Google Android eto neslojno. Sbornik urokov. Elektronnoe izdanie, 2012.

    5. Orlov L.V. Web-sayt bez sekretov. 2-e izd. M.: ZAO “Noviy izdatelskiy dom”, 2004. -512 s.

    6. Wikipedia. Internet ensiklopediya. (ru.wikipedia.org/wiki/Android)

    7. Androidning rasmiy veb sahifasi. (android.com)

    8. Spravka – OS Android. (http://support.google.com/android/?hl=ru)

    9. Programmirovanie dlya android, java – s samix pervix shagov. (http://davidmd.ru/tag/eclipse/)

    10. API Guides for Android App.

    (http://developer.android.com/guide/components/index.html)

    11. D.Vinogradov. Start Andorid. (Sbornik urokov) – 2012. 703 b.


    ILOVALAR

    MainActivity.java

    package com.example.dj;

    import android.os.Bundle;

    import android.app.ListActivity;

    import android.content.Intent;

    import android.database.Cursor;

    import android.view.ContextMenu;

    import android.view.ContextMenu.ContextMenuInfo;

    import android.view.Menu;

    import android.view.MenuItem;

    import android.view.View;

    import android.widget.AdapterView.AdapterContextMenuInfo;

    import android.widget.ListView;

    import android.widget.SimpleCursorAdapter;

    import android.widget.Spinner;

    public class MainActivity extends ListActivity {

    private ToDoDatabase dbHelper;

    private static final int ACTIVITY_CREATE = 0;

    private static final int ACTIVITY_EDIT = 1;

    private static final int DELETE_ID = Menu.FIRST 1;

    private Cursor cursor;

    private Spinner Kunlar;

    @Override

    protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);

    // setContentView(R.layout.activity_main);

    setContentView(R.layout.main);

    Kunlar = (Spinner) findViewById(R.id.Kunlar);

    String kunlar = (String) Kunlar.getSelectedItem();

    this.getListView().setDividerHeight(2);

    dbHelper = new ToDoDatabase(this);

    fillData();

    registerForContextMenu(getListView());

    }

    @Override



    public boolean onCreateOptionsMenu(Menu menu) {

    getMenuInflater().inflate(R.menu.main, menu);

    return true;

    }
    @Override

    public boolean onMenuItemSelected(int featureId, MenuItem item) {

    switch (item.getItemId()) {

    case R.id.insert:

    createNewTask();

    return true;

    }

    return super.onMenuItemSelected(featureId, item);



    }

    @Override

    public boolean onOptionsItemSelected(MenuItem item) {

    switch (item.getItemId()) {

    case R.id.insert:

    createNewTask();

    return true;

    }

    return super.onOptionsItemSelected(item);



    }

    @Override

    public boolean onContextItemSelected(MenuItem item) {

    switch (item.getItemId()) {

    case DELETE_ID:

    AdapterContextMenuInfo info = (AdapterContextMenuInfo) item

    .getMenuInfo();

    dbHelper.deleteTodo(info.id);

    fillData();

    return true;

    }

    return super.onContextItemSelected(item);



    }

    private void createNewTask() {

    Intent intent = new Intent(this, EditActivity.class);

    startActivityForResult(intent, ACTIVITY_CREATE);

    }

    private void fillData() {



    cursor = dbHelper.getAllTodos();

    startManagingCursor(cursor);

    String[] from = new String[] { ToDoDatabase.COLUMN_SUMMARY };

    int[] to = new int[] { R.id.label };

    String[] from1 = new String[] { ToDoDatabase.COLUMN_CATEGORY };

    int[] to1 = new int[] { R.id.kun };

    SimpleCursorAdapter notes = new SimpleCursorAdapter(this,

    R.layout.list_row, cursor, from, to);

    SimpleCursorAdapter notes1 = new SimpleCursorAdapter(this,

    R.layout.list_row, cursor, from1, to1);

    setListAdapter(notes);

    setListAdapter(notes1);

    }

    @Override



    protected void onListItemClick(ListView l, View v, int position, long id) {

    super.onListItemClick(l, v, position, id);

    Intent intent = new Intent(this, EditActivity.class);

    intent.putExtra(ToDoDatabase.COLUMN_ID, id);

    // ushbu metod orqali activity natija qaytaradi

    startActivityForResult(intent, ACTIVITY_EDIT);

    }

    @Override



    protected void onActivityResult(int requestCode, int resultCode,

    Intent intent) {

    super.onActivityResult(requestCode, resultCode, intent);

    if (resultCode == RESULT_OK) {

    fillData();

    }

    }



    @Override

    public void onCreateContextMenu(ContextMenu menu, View v,

    ContextMenuInfo menuInfo) {

    super.onCreateContextMenu(menu, v, menuInfo);

    menu.add(0, DELETE_ID, 0, R.string.menu_delete);

    }

    @Override



    protected void onDestroy() {

    super.onDestroy();

    if (dbHelper != null) {

    dbHelper.close();

    }

    }

    }


    ToDoDatabase.java

    package com.example.dj;


    import android.content.ContentValues;

    import android.content.Context;

    import android.database.Cursor;

    import android.database.SQLException;

    import android.database.sqlite.SQLiteDatabase;

    import android.database.sqlite.SQLiteOpenHelper;

    import android.os.Bundle;

    import android.util.Log;


    public class ToDoDatabase extends SQLiteOpenHelper {
    private static final String DATABASE_NAME = "todo_app.db";

    private static final int DATABASE_VERSION = 1;

    private static final String DATABASE_TABLE = "todos";
    // Jadval ustunlari

    public static final String COLUMN_ID = "_id";

    public static final String COLUMN_CATEGORY = "category";

    public static final String COLUMN_SUMMARY = "summary";

    public static final String COLUMN_DESCRIPTION = "description";
    // Ma’lumotlar bazasini yaratish uchun so’rov yuborish

    private static final String DATABASE_CREATE = "create table "

    DATABASE_TABLE "(" COLUMN_ID

    " integer primary key autoincrement, " COLUMN_CATEGORY

    " text not null, " COLUMN_SUMMARY " text not null,"

    COLUMN_DESCRIPTION " text not null" ");";


    public ToDoDatabase(Context context) {

    super(context, DATABASE_NAME, null, DATABASE_VERSION);

    }
    @Override

    public void onCreate(SQLiteDatabase db) {

    // TODO Auto-generated method stub

    db.execSQL(DATABASE_CREATE);

    }
    @Override

    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

    // TODO Auto-generated method stub

    Log.w(ToDoDatabase.class.getName(), "Upgrading database from version "

    oldVersion " to " newVersion

    ", which will destroy all old data");

    db.execSQL("DROP TABLE IF EXISTS todos");

    onCreate(db);

    }

    public long createNewTodo(String category, String summary,



    String description) {

    SQLiteDatabase db = this.getWritableDatabase();

    ContentValues initialValues = createContentValues(category, summary,

    description);

    long row = db.insert(DATABASE_TABLE, null, initialValues);

    db.close();


    return row;

    }

    /**



    * ro’yxatni yangilaydi

    */

    public boolean updateTodo(long rowId, String category, String summary,



    String description) {

    SQLiteDatabase db = this.getWritableDatabase();

    ContentValues updateValues = createContentValues(category, summary,

    description);


    return db.update(DATABASE_TABLE, updateValues, COLUMN_ID "=" rowId,

    null) > 0;

    }
    /**

    * ro’yxat elementlarini o’chiradi

    */

    public void deleteTodo(long rowId) {



    SQLiteDatabase db = this.getWritableDatabase();

    db.delete(DATABASE_TABLE, COLUMN_ID "=" rowId, null);

    db.close();

    }
    /**

    *

    * @return hamma satrlar kursorlarini qaytaradi



    */

    public Cursor getAllTodos() {

    SQLiteDatabase db = this.getWritableDatabase();

    Cursor mCursor = db.query(DATABASE_TABLE, new String[] { COLUMN_ID,

    COLUMN_CATEGORY, COLUMN_SUMMARY, COLUMN_DESCRIPTION }, COLUMN_CATEGORY "='Dushanba'",

    null, null, null, null);

    if (mCursor != null) {

    mCursor.moveToFirst();

    }

    return mCursor;



    }
    /**

    * Ko’rsatilgan satrdagi kursor qiymatini qaytaradi

    */

    public Cursor getTodo(long rowId) throws SQLException {



    SQLiteDatabase db = this.getReadableDatabase();

    Cursor mCursor = db.query(true, DATABASE_TABLE,

    new String[] { COLUMN_ID, COLUMN_CATEGORY, COLUMN_SUMMARY,

    COLUMN_DESCRIPTION }, COLUMN_ID "=" rowId, null,

    null, null, null, null);

    if (mCursor != null) {

    mCursor.moveToFirst();

    }

    return mCursor;



    }

    /*

    * Qiymatlarni bazaga yozib qo’yish



    */

    private ContentValues createContentValues(String category, String summary,

    String description) {

    ContentValues values = new ContentValues();

    values.put(COLUMN_CATEGORY, category);

    values.put(COLUMN_SUMMARY, summary);

    values.put(COLUMN_DESCRIPTION, description);

    return values;

    }

    }
    EditActivity.java



    package com.example.dj;

    import android.os.Bundle;

    import android.app.Activity;

    import android.database.Cursor;

    import android.text.TextUtils;

    import android.util.Log;

    import android.view.View;

    import android.widget.Button;

    import android.widget.EditText;

    import android.widget.Spinner;

    import android.widget.Toast;
    public class EditActivity extends Activity {
    private EditText mTitleText;

    private EditText mBodyText;

    private Long mRowId;

    private ToDoDatabase mDbHelper;

    private Spinner mCategory;
    @Override

    protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    mDbHelper = new ToDoDatabase(this);
    setContentView(R.layout.edit_main);
    mCategory = (Spinner) findViewById(R.id.category);

    mTitleText = (EditText) findViewById(R.id.todo_edit_summary);

    mBodyText = (EditText) findViewById(R.id.todo_edit_description);
    Button confirmButton = (Button) findViewById(R.id.todo_edit_button);

    mRowId = null;

    Bundle extras = getIntent().getExtras();

    mRowId = (savedInstanceState == null) ? null

    : (Long) savedInstanceState

    .getSerializable(ToDoDatabase.COLUMN_ID);

    if (extras != null) {

    mRowId = extras.getLong(ToDoDatabase.COLUMN_ID);

    }
    populateFields();
    confirmButton.setOnClickListener(new View.OnClickListener() {

    public void onClick(View view) {

    if (TextUtils.isEmpty(mTitleText.getText().toString())) {

    Toast.makeText(EditActivity.this, "Berilganlar kiritilmagan",

    Toast.LENGTH_LONG).show();

    } else {


    saveState();

    setResult(RESULT_OK);

    finish();

    }

    }



    });

    }

    private void populateFields() {



    if (mRowId != null) {

    Cursor todo = mDbHelper.getTodo(mRowId);

    startManagingCursor(todo);

    String category = todo.getString(todo

    .getColumnIndexOrThrow(ToDoDatabase.COLUMN_CATEGORY));
    for (int i = 0; i < mCategory.getCount(); i ) {
    String s = (String) mCategory.getItemAtPosition(i);

    Log.e(null, s " " category);

    if (s.equalsIgnoreCase(category)) {

    mCategory.setSelection(i);

    }

    }
    mTitleText.setText(todo.getString(todo



    .getColumnIndexOrThrow(ToDoDatabase.COLUMN_SUMMARY)));

    mBodyText.setText(todo.getString(todo

    .getColumnIndexOrThrow(ToDoDatabase.COLUMN_DESCRIPTION)));

    todo.close();

    }

    }

    @Override



    protected void onSaveInstanceState(Bundle outState) {

    super.onSaveInstanceState(outState);

    //saveState();

    //outState.putSerializable(ToDoDatabase.COLUMN_ID, mRowId);

    }
    @Override

    protected void onPause() {

    super.onPause();

    //saveState();

    }

    @Override



    protected void onResume() {

    super.onResume();

    populateFields();

    }

    private void saveState() {



    String category = (String) mCategory.getSelectedItem();

    String summary = mTitleText.getText().toString();

    String description = mBodyText.getText().toString();

    if (description.length() == 0 && summary.length() == 0) {

    return;

    }

    if (mRowId == null) {



    long id = mDbHelper.createNewTodo(category, summary, description);

    if (id > 0) {

    mRowId = id;

    }

    } else {



    mDbHelper.updateTodo(mRowId, category, summary, description);

    }

    }



    }
    List_row.xml

    "1.0" encoding="utf-8"?>

    "http://schemas.android.com/apk/res/android"

    android:layout_width="wrap_content"

    android:layout_height="match_parent"

    android:orientation="vertical" >



    android:layout_width="fill_parent"

    android:layout_height="wrap_content"

    android:orientation="horizontal" >



    android:id="@ id/icon"

    android:layout_width="30dp"

    android:layout_height="40dp"

    android:layout_marginLeft="4dp"

    android:layout_marginRight="8dp"

    android:layout_marginTop="8dp"

    android:src="@drawable/ic_launcher" >





    android:id="@ id/label"

    android:layout_width="fill_parent"

    android:layout_height="wrap_content"

    android:layout_marginTop="6dp"

    android:textColor="@color/black"

    android:textSize="30sp" >





    android:id="@ id/kun"

    android:layout_width="fill_parent"

    android:layout_height="wrap_content"

    android:textColor="@color/black"

    android:textSize="15sp" >






    Edit_main.xml

    "1.0" encoding="utf-8"?>

    "http://schemas.android.com/apk/res/android"

    android:layout_width="fill_parent"

    android:layout_height="fill_parent"

    android:background="@color/listcolor"

    android:orientation="vertical" >

    android:id="@ id/category"

    android:layout_width="wrap_content"

    android:layout_height="wrap_content"

    android:entries="@array/priorities" >



    android:id="@ id/LinearLayout01"

    android:layout_width="fill_parent"

    android:layout_height="wrap_content" >



    android:id="@ id/todo_edit_summary"

    android:layout_width="wrap_content"

    android:layout_height="wrap_content"

    android:layout_weight="1"

    android:hint="Кратко" >







    android:id="@ id/todo_edit_description"

    android:layout_width="fill_parent"

    android:layout_height="fill_parent"

    android:layout_weight="1"

    android:gravity="top"

    android:hint="Berilishi" >






    Main.xml

    "1.0" encoding="utf-8"?>

    "http://schemas.android.com/apk/res/android"

    android:layout_width="fill_parent"

    android:layout_height="fill_parent"

    android:background="@color/listcolor"

    android:orientation="vertical" >

    android:id="@ id/Kunlar"

    android:layout_width="match_parent"

    android:layout_height="wrap_content"

    android:entries="@array/priorities"/>

    android:id="@android:id/list"

    android:layout_width="wrap_content"

    android:layout_height="wrap_content" >





    android:id="@android:id/empty"

    android:layout_width="wrap_content"

    android:layout_height="wrap_content"



    android:text="@string/no_todos" />





    * Xalq so’zi. 2001 yil, 24 may. № 101 (2663). 1-sahifa.

    ** Xalq so’zi. 2002 yil, 1 iyun. № 116 (2944). 1-2-sahifa.

    1   2   3


    Download 197.95 Kb.

    Bosh sahifa
    Aloqalar

        Bosh sahifa


    Buxoro davlat universiteti

    Download 197.95 Kb.