Advanced listview [message #1094879] |
Mon, 26 August 2013 10:28 |
Pierre Goude Messages: 1 Registered: August 2013 |
Junior Member |
|
|
Hi I am having a problem. i have created a listview with chemicals and also made it seracheble, when i press for example lol in list a new page opens thats reply with lol.
now my problem is i whant to get info from a 3.d list. so when i press lol in list a new page opens that replyes with lol and text: lought out lout mean very funny
.
in my main java i have:
package com.example.chemicals;
import java.util.ArrayList;
import java.util.List;
import android.R.string;
import android.os.Bundle;
import android.provider.ContactsContract.Data;
import android.app.Activity;
import android.app.ListActivity;
import android.content.Intent;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.Menu;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.Toast;
public class MainActivity extends ListActivity {
EditText filterText;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, android.R.id.text1,
getMode1());
final ArrayAdapter<String> adapter1 = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_2, android.R.id.text2,
getMode2());
setListAdapter(adapter);
filterText = (EditText) findViewById(R.id.filterText);
filterText.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before,
int count) {
adapter.getFilter().filter(s. toString());
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count,
int after) {
// TODO Auto-generated method stub
}
@Override
public void afterTextChanged(Editable s) {
// TODO Auto-generated method stub
}
});
}
private List<String> getMode1() {
List<String> list = new ArrayList<String>();
list.add("Aabiton");
list.add("Aagrano");
list.add("Aanectra");
list.add("Aaventa");
list.add("Abavit");
list.add("Abietinsyra");
list.add("Absorptionsmedel");
list.add("Acenaften");
list.add("Acetal");
list.add("Acetaldehyd");
list.add("Acetaldehyddietylacetal");
list.add("Acetaldehydoxim");
list.add("Acetamid");
return list;
}
private List<String> getMode2() {
List<String> datan = new ArrayList<String>();
datan.add("response 1");
datan.add("response 2");
datan.add("blaha");
datan.add("blaha");
datan.add("dsfg");
datan.add("Abietinsyra");
datan.add("Absorptionsmedel");
datan.add("Acenaften");
datan.add("Acetal");
datan.add("Acetaldehyd");
datan.add("Acetaldehyddietylacetal");
datan.add("Acetaldehydoxim");
datan.add("Acetamid");
return datan;
}
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
super.onListItemClick(l, v, position, id);
// Get the item that was clicked
Object o = this.getListAdapter().getItem(position);
String keyword = o.toString();
// Launching new Activity on selecting single List Item
Intent ii=new Intent(MainActivity.this, SingleListItem.class);
ii.putExtra("list", keyword);
startActivity(ii);
}
}
// Launching new Activity on selecting single List Item
Intent ii=new Intent(MainActivity.this, SingleListItem.class);
ii.putExtra("list", keyword);
startActivity(ii);
}
}
and in my second java page i have
TextView txtProduct = (TextView) findViewById(R.id.product_label);
Intent i = getIntent();
// getting attached intent data
String keyword = i.getStringExtra("list");
// displaying selected product name
txtProduct.setText(keyword);
}
}
}
how do i get data from a 3:d list in here?
|
|
|
|
Powered by
FUDForum. Page generated in 0.08291 seconds