0
我是新手。我正在編輯SDK中提供的可搜索字典。 詞典遵循數據庫\水庫\原材料\ definitions.txt如何在ViewText上添加換行符?
當搜索詞顯示結果(認定中)像如下─
line1 line2 line3
但我想對結果並顯示(認定中)加換行符像如下─
line1
line2
line3
WordActivity.java的代碼是在這裏
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.word);
Uri uri = getIntent().getData();
Cursor cursor = managedQuery(uri, null, null, null, null);
if (cursor == null) {
finish();
} else {
cursor.moveToFirst();
TextView word = (TextView) findViewById(R.id.word);
TextView definition = (TextView) findViewById(R.id.definition);
int wIndex = cursor.getColumnIndexOrThrow(DictionaryDatabase.KEY_WORD);
int dIndex = cursor.getColumnIndexOrThrow(DictionaryDatabase.KEY_DEFINITION);
word.setText(cursor.getString(wIndex));
definition.setText(cursor.getString(dIndex));
}}
public void onBackPressed() {
onSearchRequested();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.options_menu, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
// TODO Auto-generated method stub
case R.id.search:
onSearchRequested();
return true;
case R.id.about:
setContentView(R.layout.abouttanzil);
return true;
case R.id.exit:
moveTaskToBack(true);
return true;
default:
return false;
}
}
}
請讓我知道我應該添加什麼以及在哪裏進行換行? 在此先感謝。
line1是用於一個TextView,line2用於第二個等等? – Sajmon
感謝您的回覆。它像一條線包含:藥物名稱:Cepro,價格:50.我想在兩條線之間添加換行符。 – Tanzil