تبدیل رشته متنی به عدد در اندروید
Integer.parseInt("123");
Tags:
Converting a string to an integer (Android)
Android: converting String to int
Integer.parseInt("123");
Tags:
Converting a string to an integer (Android)
Android: converting String to int
کد روبرو ممکن است منجر به این خطا شود در حالیکه متغیر db به درستی بسته شده است.
DBAdapter db = new DBAdapter(this);
db.open();
//load all waiting alarm
mCursor=db.getTitles("state<2");
setListAdapter(new MyCursorAdapter(this, mCursor));
db.close();
راه حل این مشکل mCursor.close(); نیست، چون ممکن است DBAdapter به درستی کار نکند.
از دستور startManagingCursor() قبل از db.close(); استفاده کنید.
در اکتیویتی اول یک intent می سازیم و اکتیویتی دوم را به ترتیب زیر صدا می زنیم
Intent intent1 = new Intent(this, Class2.class);
intent1.putExtra("foo", 5.0f);
intent1.putExtra("bar", "baz");
startActivity(intent1);
در اکتیویتی دوم، به ترتیب زیر مقادیر فرستاده شده توسط اکتیویتی اول را می خوانیم
Bundle extras = getIntent().getExtras();
if(extras !=null)
{
float foo = extras.getFloat("foo");
String bar = extras.getString("bar");
}