如何定期而不是随机更改 toast 消息。我使用随机字符串来更改 toast 消息。但我想定期(按顺序)更改它
How to change toast message regularly not random. I use random string to change the toast messages. but I want to change regular (in order) it
// 这是我的数据库,有 3 个字符串。
public class kelimeVeriTabani {
public String[][] fil = { { "message 1", "first " }, { "message 2", "second" }, { "message 3", "third " },}}
// 这是我的 activity 每 15 秒更改一次 toast 消息。
public class fil extends Activity {
kelimeVeriTabani kelimeVeriTabani = new kelimeVeriTabani();
.
.
.
TextView text = (TextView) layout.findViewById(R.id.text);
// I set Random but
// I want to regular. I do not find the code
Random ran = new Random();
int i = ran.nextInt(kelimeVeriTabani.fil.length);
text.setText(kelimeVeriTabani.fil[i][0] + " = " + kelimeVeriTabani.fil[i][1]);
toast.show();
.
.
.
你想要什么?
也许是这样的?
public class baglaccalistirici extends Activity {
static int i=0;
database database = new database();
//Random ran = new Random();
text.setText(database.messages[i][0] + " = " + database.messages[i][1]);
if(++i==database.messages.length)i=0;
}
PS: 下次发布之前检查你的代码格式。
// 这是我的数据库,有 3 个字符串。
public class kelimeVeriTabani {
public String[][] fil = { { "message 1", "first " }, { "message 2", "second" }, { "message 3", "third " },}}
// 这是我的 activity 每 15 秒更改一次 toast 消息。
public class fil extends Activity {
kelimeVeriTabani kelimeVeriTabani = new kelimeVeriTabani();
.
.
.
TextView text = (TextView) layout.findViewById(R.id.text);
// I set Random but
// I want to regular. I do not find the code
Random ran = new Random();
int i = ran.nextInt(kelimeVeriTabani.fil.length);
text.setText(kelimeVeriTabani.fil[i][0] + " = " + kelimeVeriTabani.fil[i][1]);
toast.show();
.
.
.
你想要什么?
也许是这样的?
public class baglaccalistirici extends Activity {
static int i=0;
database database = new database();
//Random ran = new Random();
text.setText(database.messages[i][0] + " = " + database.messages[i][1]);
if(++i==database.messages.length)i=0;
}
PS: 下次发布之前检查你的代码格式。