Nosirova Shahnoza Umidovna mavzu: Android operatsion tizimida dars jadvali yaratish



Download 0,83 Mb.
bet16/17
Sana30.12.2021
Hajmi0,83 Mb.
#92124
1   ...   9   10   11   12   13   14   15   16   17
Bog'liq
Buxoro davlat universiteti

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);

}

}



}


Download 0,83 Mb.

Do'stlaringiz bilan baham:
1   ...   9   10   11   12   13   14   15   16   17




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish