我想在使用ViewPager的佈局中設置TextView的文本。這是我有的代碼:ViewPager:SetText的充氣視圖
setContentView(R.layout.main);
MyPagerAdapter adapter = new MyPagerAdapter();
ViewPager myPager = (ViewPager) findViewById(R.id.Panel);
myPager.setAdapter(adapter);
myPager.setCurrentItem(0);
String text;
if (Math.floor(hours) <= 12)
text= hourFormat.format((Math.floor(hours)));
else
text= hourFormat.format((Math.floor(hours) - 12));
Typeface FontType = Typeface.createFromAsset(this.getAssets(),"fonts/TIMES_SQ_0.TTF");
View sResource = getLayoutInflater().inflate(R.layout.setup, null);
Method = (TextView) sResource.findViewById(R.id.Method);
Method.setTypeface(FontType);
Method.setTextSize(20);
Method.setText(text);
ViewPager工作正常,設置字體和大小不起作用。設置文字也不起作用。我不知道爲什麼setText不起作用。此外,該文本是動態的,所以我不能使用資源字符串來設置它。
澄清:小時是一天中的小時。
只是一個筆記 - 設置字體就像你會在ICS前的設備內存泄漏 - http://stackoverflow.com/questions/8057010/listview-memory-leak – 2012-08-12 22:55:16
感謝您的提示,我沒有' t知道 – mgalal 2012-08-12 22:57:58