I'm currently trying to extend an example that I found on http://jsharkey.org/blog/2008/08/18/separating-lists-with-headers-in-android-09/.
I first extended this by creating an EditText to function as my search bar and then followed a few tutorials to implement the Filter function. What I'm trying to do is when a user inputs a text, if the section has matching text, return the section and all its sub-items. If a sub-item is searched return its section and the sub-item matching the constraint. My functions work when there is no sections however it does not work at all with the sections.
Help would be greatly appreciated.
main_list.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.myapplication">
<EditText
android:id="#+id/search_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:drawableRight="#android:drawable/ic_menu_search"
android:hint="Search"
android:lines="1"
android:maxLines="1"
android:maxWidth="100dp"
android:minWidth="300dp"
android:singleLine="true"/>
<ListView
android:id="#+id/list_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/search_text"/>
</RelativeLayout>
I then modified a bit of the main activity so that I can implement the search bar.
ListSample.java
public class ListSample extends Activity {
SeparatedListAdapter adapter;
#Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.main_list);
ListView listView = (ListView) findViewById(R.id.list_view);
EditText inputSearch = (EditText) findViewById(R.id.search_text);
List<String> america = new ArrayList<>();
america.add("Chicago");
america.add("Washington");
List<String> australia = new ArrayList<>();
australia.add("Sydney");
australia.add("Melbourne");
australia.add("Perth");
List<String> combined = new ArrayList<>();
combined.addAll(america);
combined.addAll(australia);
// create our list and custom adapter
adapter = new SeparatedListAdapter(this, combined);
adapter.addSection("America", new ArrayAdapter<String>(this,
R.layout.list_item, america));
adapter.addSection("Australia", new ArrayAdapter<String>(this,
R.layout.list_item, australia));
listView.setAdapter(adapter);
inputSearch.addTextChangedListener(new TextWatcher() {
#Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
#Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
adapter.getFilter().filter(s.toString());
}
#Override
public void afterTextChanged(Editable s) {
}
});
}
}
Filter fucntions
#Override
public Filter getFilter() {
if(filter == null){
filter = new dataFilter();
}
return filter;
}
private class dataFilter extends Filter{
#Override
protected FilterResults performFiltering(CharSequence constraint) {
FilterResults results = new FilterResults();
constraint = constraint.toString().toLowerCase(Locale.getDefault());
ArrayList<String> filterList = new ArrayList<String>();
if(constraint != null && constraint.length() > 0){
for(int i =0; i < originalDataFilterList.size(); i++){
if(originalDataFilterList.get(i).toLowerCase().contains(constraint.toString().toLowerCase())){
filterList.add(originalDataFilterList.get(i));
}
}
results.count = filterList.size();
results.values = filterList;
} else {
results.count = originalDataFilterList.size();
results.values = originalDataFilterList;
}
return results;
}
#Override
protected void publishResults(CharSequence constraint, FilterResults results){
originalData = (ArrayList<String>)results.values;
notifyDataSetChanged();
}
}
Currently, your filter result is stored in the originalData array without sub-section information. The code did not modify the headers adapter and sections map which are stored separately in the SeparatedListAdapter, and thus no change would occur when you change the filter and call notifyDataSetChanged().
Instead of creating and passing the combined list to the SeparatedListAdapter, and use this 'flat' list for filtering, you may need to iterate on the sections map and its adapters during the filtering, store the filtering results, and then the getItem(), getCount(), getViewTypeCount(), getItemViewType(), isEnabled(), getView() and getItemId() methods need to be rewritten to take into account the result.
There are many ways to implement this. For example, to avoid re-creating the sections and headers arrays each time your filter changes, you can calculate and store a mapping of list view position to the appropriate header and subitem (by storing the offset for headers / adapter and position for subitems), for application by methods such as getItem() accordingly. You also need to calculate the total count (for retrieval by getCount()).
Related
I am newbie in Android development, and currently I am facing problem with my project, I want to connect my app to local host, I have seen the ways to do that and picked up the simplest one using json, thus I stopped on the way of implementing my TextWatcher adding it in to that code. The rest of the things I have done as it requires on steps.
Please take a look at my code and tell me what is my mistake?
this is my Java code:
public class MyActivity extends Activity implements TextWatcher {
HttpClient httpClient;
private HttpPost mhttpPost;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
String[] mobileArray = {"Laptops","IPhone","WindowsMobile","Blackberry","WebOS","Ubuntu","Windows7","Max OS X"};
ArrayAdapter adapter = new ArrayAdapter<String>(this,R.layout.list_item,mobileArray);
ListView listView = (ListView) findViewById(R.id.listView);
listView.setAdapter(adapter);
httpClient = new DefaultHttpClient();
mhttpPost = new HttpPost("http://10.0.2.1/index/get_for_mobile");
try {
HttpResponse response = httpClient.execute(mhttpPost);
HttpEntity ent = response.getEntity();
String temp = EntityUtils.toString(response.getEntity());
}
catch (Exception e ){}
}
private TextWatcher search = new TextWatcher() {
#Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
#Override
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
#Override
public void afterTextChanged(Editable editable) {
}
};
}
and here is my xml code:
<!-- The primary full-screen view. This can be replaced with whatever view
is needed to present your content, e.g. VideoView, SurfaceView,
TextureView, etc. -->
<!-- This FrameLayout insets its children based on system windows using
android:fitsSystemWindows. -->
<SearchView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/searchView"
android:layout_marginBottom="48dp" />
<ListView
android:layout_width="wrap_content"
android:layout_height="399dp"
android:id="#+id/listView"
android:layout_gravity="right|top"
android:choiceMode="multipleChoice" android:clickable="true"/>
you have not added textwatcher to EditText or any View ,of which text event you want handle .see http://developer.android.com/reference/android/text/TextWatcher.html
Why you need to implement textwacther whicile ending json to localhost .
Here I am taking three ArrayList (EmpName, EmpID and EmpPhone).
In this, I am storing 5 data in each arraylist and after that I'm trying to show
all data on listview like in each row of list view there will be 3 data.but I'm not
getting exact output. Here my entire code...Please help... Thank you.
activity_main.xml
<ListView
android:id="#+id/main_listView1"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</ListView>
custom_checkbox.xml
<TextView
android:id="#+id/custom_empname_textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/custom_empid_textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/custom_empphone_textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge" />
MainActivity.java
public class MainActivity extends Activity {
ArrayList<String> EmpName;
ArrayList<String> EmpID;
ArrayList<String> EmpMobile;
void getEmpDetails() {
EmpName.add("Jhon");
EmpName.add("Joy");
EmpName.add("Jain");
EmpName.add("Jason");
EmpName.add("Joky");
EmpID.add("1001");
EmpID.add("1002");
EmpID.add("1003");
EmpID.add("1004");
EmpID.add("1005");
EmpMobile.add("8179789878");
EmpMobile.add("8179789478");
EmpMobile.add("8179789378");
EmpMobile.add("8179789278");
EmpMobile.add("8179789678");
}
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ListView list = (ListView)findViewById(R.id.main_listView1);
}
class ListAdapter extends BaseAdapter {
#Override
public int getCount() {
// TODO Auto-generated method stub
return EmpName.size();
}
#Override
public Object getItem(int arg0) {
// TODO Auto-generated method stub
return null;
}
#Override
public long getItemId(int arg0) {
// TODO Auto-generated method stub
return 0;
}
#Override
public View getView(int index, View v, ViewGroup vg) {
// TODO Auto-generated method stub
v = getLayoutInflater().inflate(R.layout.custom_checkbox, null);
TextView t1 = (TextView)v.findViewById(R.id.custom_empname_textView);
TextView t2 = (TextView)v.findViewById(R.id.custom_empid_textView);
TextView t3 = (TextView)v.findViewById(R.id.custom_empphone_textView);
EmpName = new ArrayList<String>();
EmpID = new ArrayList<String>();
EmpMobile = new ArrayList<String>();
getEmpDetails();
ArrayAdapter<String> a1 =
new ArrayAdapter<String>(MainActivity.this, android.R.layout.simple_list_item_1, EmpName);
ArrayAdapter<String> a2 =
new ArrayAdapter<String>(MainActivity.this, android.R.layout.simple_list_item_1, EmpID);
ArrayAdapter<String> a3 =
new ArrayAdapter<String>(MainActivity.this, android.R.layout.simple_list_item_1, EmpMobile);
t1.setText((CharSequence) a1);
t2.setText((CharSequence) a2);
t3.setText((CharSequence) a3);
return null;
}
}
}
Based on your questions and issues, I would suggest you below points:
Manage a single ArrayList:
Managing different ArrayLists for the same object would be hard to manage. Like you are managing 3 ArrayList for storing information of Employee. Instead, you should manage a single ArrayList where Employee is a class.
Get particular Employee object: You can get particular Employee object inside the getView() method by position.
You are creating ArrayAdapter inside getView() method of your custom adapter. Not required at all.
And your code requires so many changes, better you get any android book and learn Android programming well.
Your code will not work, because you are using adapter wrong (and not setting to ListView at all).
Unfortunately, your code needs too many changes (for example, you should change new object Employee, you should pass array of these objects to adapter and bing values of Employee to item views) for resolving it in my answer, so just read good tutorial about adapters and try to write this code again:
http://www.javacodegeeks.com/2013/09/android-listview-with-adapter-example.html
http://www.vogella.com/tutorials/AndroidListView/article.html
Hope it helps.
I have an activity with a list of Products (like a shopping list), in which we can choose the number of product units.
The activity contains EditText with TextWatcher and a ListView with a personal Adapter (extends BaseAdapter).
When I type a key in the EditText, the listView of products is refreshed with the new data.
But I would like to keep the state of my selected data.
For example, I type a reference in the EditText, then the listView contains 3 datas (A, B, C), I choose A, and type 5 units of it, then I type a new reference in the EditText (A and B disappears).
The listView contain only C, but I remove my search and go back to A, B, C.
the problem, the product A is unselected and have 0 of units (the 5 units have disappeared).
I would like to keep the selected products and the units even if I change my search in the EditText.
How to do that please ?
Here is a code snippet :
The layout of the activity :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<EditText
android:id="#+building_list/search_box"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="Filter by reference"
android:inputType="textAutoCorrect|none|textAutoComplete|none|textNoSuggestions"
android:maxLines="1"
android:textSize="20dp" />
<ListView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginLeft="10dp"
android:id="#+id/productListView">
</ListView>
</LinearLayout>
The Adapter :
public class AdapterProduct extends BaseAdapter {
private List<Product> lstProduct;
private LayoutInflater mInflater;
public AdapterProduct(Context context, List<Product> listP) {
lstProduct = listP;
mInflater = LayoutInflater.from(context);
}
public View getView(int position, View convertView, ViewGroup parent) {
CheckedLinearLayout layoutItem;
if (convertView == null) {
layoutItem = (CheckedLinearLayout) mInflater.inflate(R.layout.row_product, parent, false);
final ViewHolderProduct viewHolder;
viewHolder = new ViewHolderProduct();
viewHolder.btPlusAmount = (Button)layoutItem.findViewById(R.id.btPlusAmount);
viewHolder.btPlusAmount.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
Product p = (Product) viewHolder.product.getTag();
p.setAmount(p.getAmount()+1);
notifyDataSetChanged();
}
});
}
else {
layoutItem = (CheckedLinearLayout) convertView;
((ViewHolderProduct) layoutItem.getTag()).btPlusAmount.setTag(lstProduct.get(position));
}
ViewHolderProduct viewHolder = (ViewHolderProduct) layoutItem.getTag();
viewHolder.amount.setText(String.valueOf(lstProduct.get(position).getAmount()));
}
static class ViewHolderProduct {
protected TextView amount;
protected Button btPlusAmount;
}
}
And the AsyncTask with TextWatcher :
AsyncTask
doInBackground =>
modelProduct = new AdapterProduct(leContext,
ProductJSON.getService().searchProducts(leContext, url, params[0])); //params[0] = the text of EditText
private TextWatcher filterTextWatcher = new TextWatcher() {
public void afterTextChanged(Editable s) {
}
public void beforeTextChanged(CharSequence s, int start, int count,
int after) {
}
public void onTextChanged(CharSequence s, int start, int before,
int count) {
//AsyncTask task
task.execute(s.toString());
}
};
I let you check my answer here.
1) Basically, add a new attribute to your adapter. A simple int[] is enough. Store the number of products selected inside.
2) Each time you build the View of a row of your ListView, check the number of products selected.
3)Make sure to update the number of products selected when you click on the button. Also, make sure to resize/update this array when your List changes. Call notifyDataSetChanged() Each Time you click on a product.
I'm still very new to application development, so this is probably a very stupid question but I can't seem to find the right answer (or at least one that I can understand with my very limited knowledge of java).
I'm using a custom ArrayAdapter called ListRow. It works fine with a regular Activity, but not with the ListActivity that I need it to be in for my app to work.
Below is a sample of the code that I'm using. Any help would be greatly appreciated and you'd be helping a ton!
ListView mListview;
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setListAdapter(new ListRow(this, THEME_NAMES, THEME_ICONS));
getListView().setTextFilterEnabled(true);
}
public class ListRow extends BaseAdapter {
private Context mContext;
private String[] mThemeNames = THEME_NAMES;
private int[] mThemeIcons = THEME_ICONS;
public ListRow(Context c, String[] t, int[] i) {
mContext = c;
mThemeNames = t;
mThemeIcons = i;
mListview=(ListView)findViewById(R.id.list);
}
#Override
public int getCount() {
return mThemeNames.length;
}
#Override
public Object getItem(int arg0) {
return null;
}
#Override
public long getItemId(int arg0) {
return 0;
}
#Override
public View getView(int position, View converView, ViewGroup parent) {
View List;
if(converView==null){
List=new View(mContext);
LayoutInflater mLayoutinflater=getLayoutInflater();
List=mLayoutinflater.inflate(R.layout.list_view, parent, false);
} else {
List = (View)converView;
}
ImageView imageView = (ImageView)List.findViewById(R.id.image);
TextView textView = (TextView)List.findViewById(R.id.text);
imageView.setImageResource(mThemeIcons[position]);
textView.setText(mThemeNames[position]);
return List;
}
}
And here's the layout I've defined for each list item
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="center"
android:id="#+id/image"
android:layout_alignParentLeft="true"
android:contentDescription="#string/preview" />
<TextView
android:id="#+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#id/image" />
</RelativeLayout>
If you can, please use small words with me lol, java has turned out to be hard to understand for me, and also try to explain as much as you can. Thanks in advance!
FIGURED IT OUT!
So I just put you all through a bit of hell. The layout that contains my list items is called list_item, not list_view. However I have learned a lot here so THANK YOU ALL VERY MUCH! I wish there were a way I could help you guys out...
Moral of this question? CHECK YOUR LAYOUT NAMES!!
You need to set The Adapter in this way
setListAdapter(new ListRow(this, your_theme_names_array, your_theme_icon_array));
You dont need to use ArrayAdapter for this, that is just for Creating a Adapter for an array of String
EDITED
The Layout XML does not have the problem i think.
Check the List given below one by one
Check List
Check Whether R.layout.list_view point to the layout you given in the Question.
Try this for setting adapter setListAdapter(new ListRow(this, String[] { }, int[] { })); it will show you blank screen (If you get the Blank Screen that means either THEME_NAMES or THEME_ICONS is null or their values is null)
Remove the Line imageView.setImageResource(mThemeIcons[position]); and
textView.setText(mThemeNames[position]); this will also give u blank screen (If you get blank screen then R.layout.list_view does not contain R.id.image or R.id.text.
You have to add your mListView in your ArrayAdapter in setListAdapter.Only then the contents of your listview will be display in the pattern you have mentioned in customadapter. I cannot see where you have added elements in listview.
I have created an RSS reader that lists items in a listview. I also want a date below each item, but I have no idea how to do that. I need someone's help to make the Sub Item text display the pubDate that was retrieved from the RSS feed.
This is the code I have for my class:
public class RSSReader extends Activity implements OnItemClickListener
{
public final String RSSFEEDOFCHOICE = "http://app.calvaryccm.com/mobile/android/v1/devos";
public final String tag = "RSSReader";
private RSSFeed feed = null;
/** Called when the activity is first created. */
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.main);
// go get our feed!
feed = getFeed(RSSFEEDOFCHOICE);
// display UI
UpdateDisplay();
}
private RSSFeed getFeed(String urlToRssFeed)
{
try
{
// setup the url
URL url = new URL(urlToRssFeed);
// create the factory
SAXParserFactory factory = SAXParserFactory.newInstance();
// create a parser
SAXParser parser = factory.newSAXParser();
// create the reader (scanner)
XMLReader xmlreader = parser.getXMLReader();
// instantiate our handler
RSSHandler theRssHandler = new RSSHandler();
// assign our handler
xmlreader.setContentHandler(theRssHandler);
// get our data via the url class
InputSource is = new InputSource(url.openStream());
// perform the synchronous parse
xmlreader.parse(is);
// get the results - should be a fully populated RSSFeed instance, or null on error
return theRssHandler.getFeed();
}
catch (Exception ee)
{
// if we have a problem, simply return null
System.out.println(ee.getMessage());
System.out.println(ee.getStackTrace());
System.out.println(ee.getCause());
return null;
}
}
public boolean onCreateOptionsMenu(Menu menu)
{
super.onCreateOptionsMenu(menu);
menu.add(Menu.NONE, 0, 0, "Refresh");
Log.i(tag,"onCreateOptionsMenu");
return true;
}
public boolean onOptionsItemSelected(MenuItem item){
switch (item.getItemId()) {
case 0:
Log.i(tag,"Set RSS Feed");
return true;
case 1:
Log.i(tag,"Refreshing RSS Feed");
return true;
}
return false;
}
private void UpdateDisplay()
{
TextView feedtitle = (TextView) findViewById(R.id.feedtitle);
TextView feedpubdate = (TextView) findViewById(R.id.feedpubdate);
ListView itemlist = (ListView) findViewById(R.id.itemlist);
if (feed == null)
{
feedtitle.setText("No RSS Feed Available");
return;
}
if(feedtitle != null)
feedtitle.setText(feed.getTitle());
if(feedpubdate != null)
feedpubdate.setText(feed.getPubDate());
ArrayAdapter<RSSItem> adapter = new ArrayAdapter<RSSItem>(this,android.R.layout.simple_list_item_1,feed.getAllItems());
itemlist.setAdapter(adapter);
itemlist.setOnItemClickListener(this);
itemlist.setSelection(0);
}
#Override
public void onItemClick(AdapterView parent, View v, int position, long id)
{
//Log.i(tag,"item clicked! [" + feed.getItem(position).getTitle() + "]");
Intent itemintent = new Intent(this,ShowDescription.class);
Bundle b = new Bundle();
b.putString("title", feed.getItem(position).getTitle());
b.putString("description", feed.getItem(position).getDescription());
b.putString("link", feed.getItem(position).getLink());
b.putString("pubdate", feed.getItem(position).getPubDate());
itemintent.putExtra("android.intent.extra.INTENT", b);
startActivity(itemintent);
}
}
This is my XML:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Android RSSReader"
android:id="#+id/feedtitle"/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text=""
android:id="#+id/feedpubdate"/>
<ListView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/itemlist"
android:fastScrollEnabled="true"/>
</LinearLayout>
This is what it looks like now in Eclipse:
This is what it looks like running:
How to make the Sub Item text display the pubDate that was retrieved from the RSS feed?
The simplest solution is probably to substitute the ArrayAdapter and the android.R.layout.simple_list_item_1 that you are using with a SimpleAdapter and the android.R.layout.simple_list_item_2 predefined layout. This layout is composed by two TextViews, with an id of android.R.id.text1 (the "item") and android.R.id.text2 (the "sub item") respectively, which you will need as a reference for the SimpleAdapter to work.
By looking at the constructor for SimpleAdapter you will notice that, apart from a Context instance and the id of a layout resource, it takes three parameters that may be new to you:
a List<? extends Map<String, ?>> instance where you put the elements you want the ListView to show. Elements are in the form of a Map, i.e. something akin to a struct composed by properties in form of name/value pairs. For example, you may use "title" and "date" as keys for the title and date of each RSS item, respectively.
an array of strings, where to put the names of the keys in each map that you want to show on the ListView.
an array of integers where you need to put the ids of the parts in the list item view where you want the single elements referenced by the keys in the preceding array of strings to be shown. For example, if you want to show the title and date of a RSS item in the "item" and "sub item" views respectively, you use new String[] { "title", "date" } as the array of strings argument, and new int[] { android.R.id.text1, android.R.id.text2 } as this argument.
A rough code example, just to give you the idea:
List<Map<String, String>> data = new ArrayList<Map<String, String>>();
for (RSSItem item : feed.getAllItems()) {
Map<String, String> datum = new HashMap<String, String>(2);
datum.put("title", item.getTitle());
datum.put("date", item.getDate().toString());
data.add(datum);
}
SimpleAdapter adapter = new SimpleAdapter(this, data,
android.R.layout.simple_list_item_2,
new String[] {"title", "date"},
new int[] {android.R.id.text1,
android.R.id.text2});
itemList.setAdapter(adapter);
The documentation states that "the maps contain the data for each row, and should include all the entries specified in the from parameter", so both title and date should always be present.
Please note that this is all off the top of my head. I haven't actually tested all the code, so you may very well encounter some quirk or bug that you need to adjust or fix on your way up.
You should have an item_list.xml file like this:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="6dp" >
<TextView
android:id="#+id/page_title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#D8000000"
android:textSize="16sp"
android:textStyle="bold" />
<TextView
android:id="#+id/page_date"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/page_title"
android:ellipsize="marquee"
android:lines="3"
android:marqueeRepeatLimit="marquee_forever"
android:textColor="#D8000000"
android:textSize="12sp" />
</RelativeLayout>
and in your listadapter in the method getview :
View row = convertView;
LayoutInflater inflater = ((Activity) mContext).getLayoutInflater();
row = inflater.inflate(R.layout.item_list, parent, false);
TextView listTitle = (TextView) row.findViewById(R.id.page_title);
listTitle.setText(title);
TextView date = (TextView) row.findViewById(R.id.page_date);
date.setText( <here put your date from RSS feed>);
return row;
this should do it!
Since you want to map multiple data items to multiple views, you can't use an ArrayAdapter. You'll have to use a SimpleAdapter instead.
Also, I noticed you're getting the RSS feed on the main UI thread. This is going to cause your application to be highly non-responsive. If you don't know what I'm talking about, take a gander at the Painless Threading article (I consider it a must read for any android developer). What you should do instead is use a Loader. They were designed for exactly you type of situation. Although they weren't introduced until API-10 you can still use them on lesser API levels via the Support Package.
create a custom listView http://saigeethamn.blogspot.com/2010/04/custom-listview-android-developer.html