Labarotoriya ishlari uchun topshiriqlar. 1. Selsiydan Kelvinga, Farengeyt va boshqalarga aylantirish uchun BaseConverter sinfini yozing. Usulda konvertatsiya qiladigan konvertatsiya usuli bo'lishi kerak.
2. StringBuilder sinfini bekor qilishni qo'llab -quvvatlash bilan yozing. Buning uchun barcha usullarni standart StringBuilderga topshiring va o'z sinfingizda undo () bajariladigan barcha amallar ro'yxatini saqlang. Bu "Jamoa" naqshini amalga oshirish bo'ladi.
3. StringBuilder -ning o'z sinfini yozing, uning holatidagi o'zgarishlar haqida boshqa ob'ektlarni xabardor qiling. Buning uchun barcha usullarni standart StringBuilderga topshiring.
6-laboratoriya mashg'uloti. Jarayonlar (activities) va hodisalar (intents)
Ishdan maqsad: Android ilovalarini yaratishda activity lardan foydalanish. Asosiy Java (activity) fayllar va layout (xml) lar strukturasi va ularni о‘zgartirish kо‘nikmalariga ega bо‘lish, bir va bir nechta activity va layout larni bir – biriga bog‘lash.
Masalaning qо‘yilishi: Android tizimida bitta oynadan ikkinchi oynaga о‘tish va orqaga (oldingi oynaga) qaytuvchi ilova yaratilsin va har bir oynada mos holda xabarlar hosil qilinsin. Mos holda xml fayllar tasnifi keltirilsin..
Ishni bajarish tartibi Androidda yangi loyiha yaratiladi va yaratilgan loyiha quyidagi kо‘rsatilgan fayllar asosida tahrirlanadi (SubActivity.java, activity_sub.xml fayllari yangi yaratiladi)
MainActivity.java.
import android.os.Bundle;
import android.app.Activity;
import android.view.*; // Menu;
import android.content.Intent;
import android.widget.TextView;
public class MainActivity extends Activity {
TextView mText;
final static int ACT_EDIT = 0;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mText = (TextView)findViewById(R.id.textView1);
}
public void mOnClick(View v) {
Intent intent = new Intent(this, SubActivity.class);
startActivity(intent);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
activity_main.xml
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="this is main activity" />
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/textView1"
android:layout_marginTop="36dp"
android:onClick="mOnClick"
android:text="Call" />