では、簡単にまとめます。リスト内のアイテムの 1 つをタップすると、最初にタップしたアイテムに関連付けられたアイテムを含む別の listView (文字列配列によって入力) に移動します。2 番目の listView では、アイテムをタップして、別の文字列配列から関連するアイテムを含む textView を表示したいと考えています。これまでのところ、最初の 2 つの listView は機能していますが、textView を機能させることができません。私はこれに2日間頭を悩ませており、非常にイライラしています. 助けていただけますか?!
ここに私の文字列xmlファイルがあります:
<string-array name="topics">
<item>Idioms</item>
<item>Travel</item>
<item>Small Talk</item>
<item>Tips</item>
<item>App Data</item>
</string-array>
<string-array name="idioms">
<item>Cash Chow</item>
<item>No Spring chicken</item>
</string-array>
<string-array name="travel">
<item>Asking for Change</item>
<item>Bus and Train Schedule</item>
</string-array>
<string-array name="idioms_description">
<item>A cash cow is a blah blah blah</item>
<item>No spring chicken means blah blah blah</item>
</string-array>
<string-array name="travel_description">
<item>This is a test for Asking for change</item>
<item>This is a test for Bus and train schedules</item>
</string-array>
そして、これが私の getIntent であり、setText が必要な場所です。これまでに試したことはすべて惨めに失敗したため、空白のままにしました。選択した配列から適切な文字列を取得する方法がわからないだけです。
public class DetailLanguagePoints extends Activity{
private int position;
private TextView mLanguagePoint;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.detail_view);
mLanguagePoint = (TextView) findViewById(R.detail.languagepoints);
Bundle extras = getIntent().getExtras();
//int[] arrayIds = new int[]{R.array.idioms, R.array.travel};
position = extras.getInt("listposition");
int[] stringarrayIds = new int[]{R.array.idioms_description, R.array.travel_description};
String[] subTopics = getResources().getStringArray(stringarrayIds[position]);
String description = subTopics[position];
final String TAG = "MyActivity";
Log.d(TAG,description);
mLanguagePoint.setText(description);
}
}
null 例外エラーの問題が何であるかがわかりました。後で呼び出しませんでしfindViewById()
たsetcontentView()
。私はそれを行い、問題を解決しました。現在は機能しています!! 提案を提供してくれたすべての人に感謝します!!