I have done an app which will display the text from the assets folder, I used EditText
to show the text content. While testing my app text are displaying perfectly in HTC
wildfire whereas in Samsung ACE
, some of the text content are missing. I really don't know what might be the reason for this...
Can anyone help me to sort it out this issue please.
EDIT:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
Intent extra = getIntent();
selectedBook = extra.getIntExtra("selectedbook", 0);
Log.v("selectedBook>>>>", ""+selectedBook);
selectedSection = extra.getIntExtra("selectedsection", 0);
Log.v("selectedSection>>>> ",""+ selectedSection );
contentTitle = extra.getStringExtra("contenttitle");
Log.v("contentTitle>>>> ",""+ contentTitle );
setContentView(R.layout.page);
layout = (LinearLayout)findViewById(R.id.layout);
view = (EditText) findViewById(R.id.text);
setTitleView();
setTextDisplay();
Spannable wordtoSpan = (Spannable) view.getText();
view.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
}
});
}
private void setTitleView() {
// TODO Auto-generated method stub
headingTitle = (TextView) findViewById(R.id.title_txt);
headingLbtn = (Button) findViewById(R.id.tbutton_left)开发者_如何学运维;
headingRbtn = (Button) findViewById(R.id.tbutton_right);
headingTitle.setText(contentTitle);
headingRbtn.setText("Bookmark");
headingLbtn.setText("Back");
headingLbtn.setVisibility(View.VISIBLE);
headingRbtn.setVisibility(View.VISIBLE);
headingLbtn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
headingRbtn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
DbHelper db = new DbHelper(PageActivity.this);
db.addNote(selectedBook, selectedSection, contentTitle, "");
Toast.makeText(PageActivity.this, "Succesfully Bookmarked this section", Toast.LENGTH_SHORT).show();
}
});
}
private void setTextDisplay() {
try {
InputStream is = getAssets().open("" + selectedBook + ".txt");
int size = is.available();
byte[] buffer = new byte[size];
is.read(buffer);
is.close();
synchronized(this){
text = new String(buffer);
Log.v("WHOLETEXT",text);
Log.v("WHOLETEXT",""+text.length());
splitTxt = text.split("@abc@")[selectedSection];
}
String splitTxts[] = splitTxt.split("@xyz@");
Log.v("SPLITTEXT",""+splitTxts.length);
if(splitTxts.length!=1){
for(int i=0;i<splitTxts.length;i++){
TextView tv = new TextView(this);
ImageView img = new ImageView(this);
Log.v("Splited position", ""+i);
Log.v("Splited Text", splitTxts[i]);
tv.setText(splitTxts[i]);
if(selectedBook==3&&selectedSection==16){
img.setImageResource(arr204_16[i]);
}else if(selectedBook==8&&selectedSection==7){
img.setImageResource(arr209_8[i]);
}else if(selectedBook==8&&selectedSection==9){
img.setImageResource(arr209_10[i]);
}else if(selectedBook==8&&selectedSection==10){
img.setImageResource(arr209_11[i]);
}else if(selectedBook==8&&selectedSection==12){
img.setImageResource(arr209_13[i]);
}else if(selectedBook==8&&selectedSection==14){
img.setImageResource(arr209_15[i]);
}else if(selectedBook==16&&selectedSection==13){
img.setImageResource(arr217_14[i]);
}else if(selectedBook==19&&selectedSection==0){
img.setImageResource(arr220_1[i]);
}else if(selectedBook==19&&selectedSection==17){
img.setImageResource(arr220_18[i]);
}
LayoutParams lp = new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
lp.gravity=Gravity.CENTER;
img.setLayoutParams(lp);
layout.addView(tv);
layout.addView(img);
}
}else
Log.v("Splited position", ""+selectedSection);
Log.v("Splited Text", text.split("@abc@")[selectedSection]);
view.setText(text.split("@abc@")[selectedSection]);
} catch (IOException e) {
// Should never happen!
Log.i("Exception", "true");
}
}
private static final int MENU_ABOUT = 1;
private static final int MENU_HELP = 2;
public boolean onCreateOptionsMenu(Menu menu) {
menu.add(0, MENU_ABOUT, 0, "Bookmarks").setIcon(R.drawable.icon_abt1);
menu.add(0, MENU_HELP, 0, "Settings").setIcon(R.drawable.ckhelp);
return true;
}
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case MENU_ABOUT:
startActivity(new Intent(PageActivity.this, BookMarksActivity.class));
finish();
return true;
case MENU_HELP:
Intent intent = new Intent();
intent.setClass(PageActivity.this, YARPreferencesActivity.class);
startActivity(intent);
return true;
}
return false;
}
@Override
protected void onResume() {
super.onResume();
SharedPreferences pref =
}
精彩评论