問候!! 我想是這樣顯示錶: -如何在android中打破數組字符串文本?
- 1 * 1 = 1
- 1 * 2 = 2
-
-
-
1 * 10 = 10
但我是abl e顯示第一行然後消失,然後顯示下一行。我想用字符串數組來顯示數字。
這裏是我的代碼: -
public class MainActivity extends Activity {
TextView txtView;
static String test[]={"","1","","1 *","","1 * 1","","1 * 1 = 1",
"","1","","1 *","","1 * 2","","1 * 2 = 2",
"","1","","1 *","","1 * 3","","1 * 3 = 3",
"","1","","1 *","","1 * 4","","1 * 4 = 4",
"","1","","1 *","","1 * 5","","1 * 5 = 5",
"","1","","1 *","","1 * 6","","1 * 6 = 6",
"","1","","1 *","","1 * 7","","1 * 7 = 7",
"","1","","1 *","","1 * 8","","1 * 8 = 8",
"","1","","1 *","","1 * 9","","1 * 9 = 9",
"","1","","1 *","","1 * 10","","1 * 10 = 10"};
Handler handler;
ImageView imageView;
Runnable runnable;
StringBuilder sb = new StringBuilder();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Intent i = getIntent();
String someVariable = i.getStringExtra("MA");
Toast.makeText(getApplicationContext(), "SomeVariable" +someVariable, 222).show();
txtView = (TextView) findViewById(R.id.greentxt_name);
handler = new Handler();
runnable = new Runnable() {
int t=0;
public void run() {
sb.append(test[t]);
t++;
if(t>=79)
{
handler.removeCallbacks(runnable) ;
txtView.setText(test[t]);
}
else
{ txtView.setText(test[t]);
handler.postDelayed(this,1000);
}
}
};
handler.postDelayed(runnable, -1000); //for initial delay..
}
}
任何答案是明顯的。
感謝的提前
看起來你可能想要使用一個listview,而每個listviews視圖都有一個tablelayout。但是你會爲此寫一個customAdapter。 –
歡迎!我想要一個一個地顯示錶格,這樣我編碼就像這樣,但我不明白如何顯示整個表格一次。 – UchihaSasuke
txtView.append(test [t]); 而不是 txtView.setText(test [t]); 希望我對你有幫助。 – user2469133