Джо Баллад Второе активити не получает ничего от первого?
Получает значение строки listView, которая кликнута юзером.
Покажите фрагмент кода с открытьем 2-го активити
lvAuthorsAndPoems.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int position, long l) {
Intent intent = new Intent(MainActivity.this, AuthorSelectedActivity.class);
intent.putExtra("authorName", authorPoemsList.get(position).getAuthorName());
startActivity(intent);
}
});
и его же метод onCreate().
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_authorselected);
lvAuthorSelected = (ListView) findViewById(R.id.lvAuthorSelected);
dbHelper = new DatabaseHelper(this);
arrayList = new ArrayList();
Intent intent = getIntent();
authorName = intent.getStringExtra("authorName");
setTitle(authorName);
dbHelper.openDatabase();
Cursor cursor = dbHelper.mDatabase.rawQuery("SELECT p.description FROM poem p, authors a WHERE p.authorID=a._id AND a.authorName LIKE '%" + authorName + "%'",null);
cursor.moveToFirst();
while(!cursor.isAfterLast()){
arrayList.add(cursor.getString(0));
cursor.moveToNext();
}
cursor.close();
arrayAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, arrayList);
lvAuthorSelected.setAdapter(arrayAdapter);
dbHelper.closeDatabase();
lvAuthorSelected.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
Intent iPoemText = new Intent(AuthorSelectedActivity.this, PoemTextActivity.class);
iPoemText.putExtra("description", arrayAdapter.getItem(i));
iPoemText.putExtra("authorName", authorName);
startActivity(iPoemText);
}
});
}