When I comment out the code for "nameAdapter = ..." or "numAdapter = ..." and leave the other one uncommented it will display the data in the listview fine. So it is able to display both separately, however, when I leave both uncommented it will only display the data involved with numAdapter. Probably a simple mistake but I can't figure out where I went wrong.
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.player);
lv = (ListView) findViewById(R.id.listView);
new Logo().execute();
new statistics().execute();
nameAdapter = new ArrayAdapter<String>(this, R.layout.simple_list_item_1, R.id.stat_name,statName);
numAdapter = new ArrayAdapter<String>(this, R.layout.simple_list_item_1, R.id.stat_number,statNum);
}
private class statistics extends AsyncTask<String, Void, String> {
//final ListView listview = (ListView) findViewById(R.id.listView);
/*String[] values = new String[]{ "Ball Control", "Crossing", "Curve",
"Dribbling", "Finishing", "Free Kick Accuracy", "Heading Accuracy", "Long Passing",
"Long Shots", "Marking", "Penalties", "Short Passing", "Shot Power", "Sliding Tackle",
"Standing Tackle", "Volleys"};*/
//String[] stats = new String[16];
#Override
protected String doInBackground(String... arg) {
Document document;
try {
document = Jsoup.connect(url).get();
num = document.select("div#stats-base p");
statNum.clear();
for (Element element : num) {
statNum.add(element.ownText());
}
name = document.select("div#stats-base span");
statName.clear();
for (Element element : name) {
statName.add(element.ownText());
}
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
#Override
protected void onPostExecute(String result) {
lv.setAdapter(nameAdapter);
lv.setAdapter(numAdapter);
}
}
player.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" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/playerPic"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" />
<ListView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/listView"
android:layout_below="#+id/playerPic"
android:layout_centerHorizontal="true"
android:layout_marginTop="104dp"/>
</RelativeLayout>
simple_list_item_1.xml:
<?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" >
<TextView android:id="#+id/stat_name"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="10dip"
android:textSize="16dip"
android:textStyle="bold"/>
<TextView
android:id="#+id/stat_number"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="10dip"
android:textSize="16dip"
android:textStyle="bold"
android:layout_below="#id/stat_name"/>
</LinearLayout>
I think there's no mystery in that behavior. The last adapter you set to lv is the one that survives.
If what you're looking for is to add both statName and statNum, I'd set one of them and afterwards use .addAll(...) on the other. For instance:
lv = lv.setAdapter(nameAdapter);
lv.addAll(statNum);
nameAdapter.notifyDataSetChanged();
Don't forget the last line to let your ListView render the new data.
Related
I cant set my ListView dynamically after getting json response from backend.
SherlockNavigationDrawer extends ActionBarActivity
Activity -
public class Forum extends SherlockNavigationDrawer implements OnClickListener {
AsyncTask<Void, String, Void> forumTask;
ProgressDialog pDialog;
TextView newPost;
Button first, last, next, prev;
ListView list;
LinearLayout nopost;
MyPostListAdapter adapter;
public static final String MyPREFERENCES = "MyPrefs";
SharedPreferences sharedpreferences;
String get = "";
JSONObject json;
JSONParser jp;
JSONArray id, user_id, user_name, date, file_path, description, title,
hut_name, hut_id, ttl_likes, ttl_comment;
#Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.forum);
setTitle("Space Huts | Forum");
// newPost = (TextView) findViewById(R.id.tv_test);
first = (Button) findViewById(R.id.bt_first);
prev = (Button) findViewById(R.id.bt_prev);
next = (Button) findViewById(R.id.bt_next);
last = (Button) findViewById(R.id.bt_last);
list = (ListView) findViewById(R.id.lv_posts);
nopost = (LinearLayout) findViewById(R.id.ll_none);
first.setOnClickListener(this);
prev.setOnClickListener(this);
next.setOnClickListener(this);
last.setOnClickListener(this);
// do a get request to server for getting latest 5 pagination posts
doGETrqst("first");
}
private void doGETrqst(final String page) {
// TODO Auto-generated method stub
forumTask = new AsyncTask<Void, String, Void>() {
#Override
protected void onPreExecute() {
super.onPreExecute();
pDialog = new ProgressDialog(Forum.this);
pDialog.setMessage("Refreshing " + page + " page.....");
pDialog.setIndeterminate(false);
pDialog.setCancelable(true);
pDialog.show();
}
#Override
protected Void doInBackground(Void... arg0) {
sharedpreferences = getSharedPreferences(MyPREFERENCES,
Context.MODE_PRIVATE);
String usrid = sharedpreferences.getString("sesid", "");
// Create URL string
String URL = "http://xxx.xxx?id="
+ usrid + "&page=" + page;
Log.i("json url ", URL);
try {
jp = new JSONParser();
JSONObject json = jp.getJSONFromUrl(URL);
id = json.getJSONArray("id");
user_id = json.getJSONArray("user_id");
user_name = json.getJSONArray("user_name");
date = json.getJSONArray("date");
file_path = json.getJSONArray("file_path");
description = json.getJSONArray("description");
title = json.getJSONArray("title");
hut_name = json.getJSONArray("hut_name");
hut_id = json.getJSONArray("hut_id");
ttl_likes = json.getJSONArray("ttl_likes");
ttl_comment = json.getJSONArray("ttl_comment");
Log.e("recieved" , id.getString(2));
} catch (Exception ex) {
Log.e("error","error");
}
return null;
}
#Override
protected void onPostExecute(Void result) {
forumTask = null;
pDialog.dismiss();
setListView();
}
};
forumTask.execute(null, null, null);
}
private void setListView() {
// TODO Auto-generated method stub
final List<Posts> listposts = new ArrayList<Posts>();
// create list view arraylist for list adapter
for (int i = 0, length = title.length(); i < length - 1; ++i) {
Posts post = new Posts();
try {
post.setHutname(hut_name.getString(i));
post.setPostname(title.getString(i));
post.setUsername(user_name.getString(i));
post.setDate(date.getString(i));
listposts.add(post);
} catch (JSONException e) {
Toast.makeText(this, "Oooppss connectivity error",
Toast.LENGTH_SHORT).show();
}
}
// if there are new posts to show , remove nopost linear layout
if (listposts.size() > 0) {
nopost.setVisibility(View.GONE);
//set the adapter
adapter = new MyPostListAdapter(listposts , Forum.this );
list.setAdapter(adapter);
}
}
#Override
public void onClick(View arg0) {
switch (arg0.getId()) {
case R.id.bt_first:
doGETrqst("first");
break;
case R.id.bt_next:
doGETrqst("next");
break;
case R.id.bt_prev:
doGETrqst("prev");
break;
case R.id.bt_last:
doGETrqst("last");
break;
}
}
}
I want to fill my list view dynamically by getting json response from backend , when user press buttons to get next or previous posts.
However there are no errors in logcat , neither the list view is shown .But this part of setListView() do works ,as my linearlayout implements View.GONE successfully -
if (listposts.size() > 0) {
nopost.setVisibility(View.GONE);
//set the adapter
adapter = new MyPostListAdapter(listposts , Forum.this );
list.setAdapter(adapter);
}
XML LAYOUT forum.xml -
<?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:background="#000000"
android:orientation="vertical"
android:weightSum="0" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="20"
android:orientation="vertical" >
<TextView
android:id="#+id/tv_newpost"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_gravity="center"
android:background="#drawable/general_buttons"
android:clickable="true"
android:text="New Post"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#drawable/click_text_color"
android:textSize="30dp" />
<LinearLayout
android:id="#+id/ll_none"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="10dp"
android:background="#drawable/shadow"
android:gravity="center"
android:orientation="vertical" >
<TextView
android:id="#+id/tv_none"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:fontFamily="sans-serif-thin"
android:text="No New Post"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#000000" />
<ImageView
android:id="#+id/iv_none"
android:layout_width="150dp"
android:layout_height="match_parent"
android:src="#drawable/none" />
</LinearLayout>
<ScrollView
android:id="#+id/sv_posts"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ListView
android:id="#+id/lv_posts"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="5dp"
android:visibility="gone" >
</ListView>
</ScrollView>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal" >
<Button
android:id="#+id/bt_first"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:background="#drawable/general_buttons"
android:paddingLeft="15dp"
android:paddingRight="20dp"
android:text="FIRST"
android:textColor="#drawable/click_text_color" />
<Button
android:id="#+id/bt_prev"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/general_buttons"
android:paddingLeft="15dp"
android:paddingRight="20dp"
android:text="<<"
android:textColor="#drawable/click_text_color" />
<Button
android:id="#+id/bt_next"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/general_buttons"
android:paddingLeft="20dp"
android:paddingRight="15dp"
android:text=">>"
android:textColor="#drawable/click_text_color" >
</Button>
<Button
android:id="#+id/bt_last"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:background="#drawable/general_buttons"
android:paddingLeft="20dp"
android:paddingRight="15dp"
android:text="LAST"
android:textColor="#drawable/click_text_color" />
</LinearLayout>
</LinearLayout>
After getting responses i updated my code like this -
in onCreate() - before doGETReqst() -
adapter = new MyPostListAdapter(listResults , Forum.this );
list.setAdapter(adapter);
in setListView() -
if (listposts.size() > 0) {
nopost.setVisibility(View.GONE);
//set the adapter
listResults.clear();
listResults.addAll(listposts);
adapter.notifyDataSetChanged();
}
My result is this, now how can i set this into scrollview, in which i nested ListView...i checked my all layouts -
Finally after removing android:view="gone" , adding adapter.notifyDataSetChanged(); and removing scrollview above listview i was able to get this -
Thank you guyz
Your adapter should be created with a List object (for example listResults) and in the setListView do something like:
if (listposts.size() > 0) {
nopost.setVisibility(View.GONE);
//clear old results
listResults.clear();
//load all results
listResults.addAll(listposts);
//notify the adapter about the changes
adapter.notifyDataSetChanged();
}
The point is... create an adapter over an list so... you have ONE instance of that list.
Then update the contents of that list (don't create a new instance), and tell the adapter that the collection has changed.
Try it and let mw know if it works.
In your layout you have android:visibility="gone" set for your listview. I don't see that being toggled in your code.
The answer about updating the adapter instead of creating a new instance is also correct. Initialize your adapter along with your listview and set it (using setAdapter) in the initialization phase. Then when your new data comes in (I modified the code given in the other answer as it was confusing - what's listResults?):
adapter.clear();
//load all results
adapter.addAll(listposts);
//notify the adapter about the changes
adapter.notifyDataSetChanged();
I have an Activity which is called when a listView item is clicked in a fragment.
My problem is that even after i make changes to my layout(setting text of textviews etc) and calling setContentView, the activity screen is blank.
From the Log.i ive used everywhere, in logcat, i can see all data and it is being properly set, so that isnt the problem.
My question is how do i make it so the changes I've made are displayed on screen/How to refresh the layout with the new data.
public class SemListViewActivity extends Activity
{
JSONObject recdJson=new JSONObject();
JSONArray ar;
ArrayList<HashMap<String, String>> keyslist;
TextView semTCredits, semSession, semGPA;
ListView semList;
SemListAdapter adapter;
#Override
protected void onCreate(Bundle savedInstanceState)
{
Log.i("Info Tag Sem","Inside Sem");
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
super.onCreate(savedInstanceState);
setContentView(R.layout.sem_details_listview_layout);
//LayoutInflater inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
//View v = inflater.inflate(R.layout.sem_details_listview_layout,null);
ar = new JSONArray();
keyslist = new ArrayList<HashMap<String, String>>();
try
{
recdJson = GlobalVars.semJSON;
Log.i("Info Tag Sem","Got the JSON");
ar = recdJson.getJSONArray("seminfo");
Log.i("Info Tag Sem","assigning JSON Array");
for (int i = 0; i < ar.length(); i++)
{
JSONObject jObject = ar.getJSONObject(i);
HashMap<String, String> map = new HashMap<String, String>();
Log.i("Info Tag Sem","jObject Init"+i);
Log.i("Info Tag Sem",jObject.toString());
Log.i("Info Tag Sem",jObject.getString("subcode"));
map.put("subcode", jObject.getString("subcode"));
map.put("sub", jObject.getString("sub"));
map.put("credits", jObject.getString("credits"));
map.put("grade", jObject.getString("grade"));
keyslist.add(map);
}
Log.i("Info Tag Sem","Done with Hashmapping");
semTCredits = (TextView)findViewById(R.id.semTCredits);
semSession = (TextView)findViewById(R.id.semSession);
semGPA = (TextView)findViewById(R.id.semGPA);
Log.i("Info Tag Sem","Set the textviews");
semTCredits.setText("Total Credits: " + recdJson.getString("credits"));
semSession.setText("Session: " + recdJson.getString("session"));
semGPA.setText("Semester GPA: " + recdJson.getString("gpa"));
semList = (ListView)findViewById(R.id.semlist);
adapter = new SemListAdapter(this, keyslist);
semList.setAdapter(adapter);
Log.i("Info Tag Sem","Put the content");
setContentView(R.layout.sem_details_listview_layout);
} catch (JSONException e)
{
e.printStackTrace();
Log.i("Info Tag Sem","Nothing happened ");
}
}
}
and this is the relevant xml layout
<?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" >
<TextView
android:id="#+id/semTCredits"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="5dp"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold" />
<TextView
android:id="#+id/semSession"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="2dp"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textIsSelectable="true" />
<TextView
android:id="#+id/semGPA"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="2dp"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textIsSelectable="true" />
<ListView
android:id="#+id/semlist"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</ListView>
</LinearLayout>
Apologies if this question is duplicate, I have no idea how to word my problem.
You are calling setContentView() twice, this second call:
Log.i("Info Tag Sem","Put the content");
setContentView(R.layout.sem_details_listview_layout);
} catch (JSONException e)
erases all of the changes that you made above... Simply remove it.
I am adding the View to the Header of ListView in the ListActivity, after inflating which has AutoCompleteTextView and not showing the suggestions on entering text. Though it works absolutely fine in normal case but not working fine when added to Header of ListView.
header_route.xml :
<?xml version="1.0" encoding="UTF-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/header"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<TextView
android:id="#+id/lblride_From"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/txtFrom"
android:layout_alignParentTop="true"
android:text="#string/lblride_Route"
/>
<AutoCompleteTextView
android:id="#+id/txtFrom"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/lblride_From"
android:layout_marginLeft="20dp"
android:layout_marginTop="2dp"
android:completionThreshold="1"
android:ems="10"
android:width="290dp"
android:imeOptions="actionGo"
android:popupBackground="#android:color/black" >
<requestFocus />
</AutoCompleteTextView>
<Button
android:id="#+id/hdbtnOkRoute"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/txtFrom"
android:layout_below="#+id/txtFrom"
android:layout_marginTop="2dp"
android:minHeight="40dp"
android:text="#string/txtBtnOk"
android:width="290dp" />
</RelativeLayout>
public class BusRouteActivity extends ListActivity implements TextWatcher {
AutoCompleteTextView actvFrom;
Button buttonOK;
TextView txtViewRouteItem;
ListView lstViewRoute;
ArrayAdapter<String> listAdapter;
DataBaseHelper databaseHelper;
TextView tvFooter;
Context appContext;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setTitle(R.string.nameBusRouteActivity);
appContext = getApplicationContext();
lstViewRoute = getListView();
LayoutInflater inflater = (LayoutInflater)appContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = inflater.inflate(R.layout.header_route, null);
DataBaseHelper dbh = new DataBaseHelper(getApplicationContext());
try {
dbh.createDataBase();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
dbh.openDataBase();
databaseHelper = dbh;
actvFrom = (AutoCompleteTextView) view.findViewById(R.id.txtFrom);
actvFrom.addTextChangedListener(this);
actvFrom.setOnEditorActionListener(actionListener);
ArrayAdapter<String> aroutes = new ArrayAdapter<String>(appContext, R.layout.routeitem, dbh.GetRoutes());
actvFrom.setAdapter(aroutes);
buttonOK = (Button)view.findViewById(R.id.hdbtnOkRoute);
buttonOK.setOnClickListener(OkOnClickListener);
tvFooter = new TextView(this);
tvFooter.setTextAppearance(getApplicationContext(), R.style.footerStyle);
String text = getResources().getString(R.string.footer);
tvFooter.setText(Html.fromHtml(text));
listAdapter = new ArrayAdapter<String>(getApplicationContext(), R.layout.routeitem);
lstViewRoute.addHeaderView(view, null, false);
lstViewRoute.addFooterView(tvFooter, null, true);
lstViewRoute.setClickable(true);
lstViewRoute.setSelected(true);
lstViewRoute.setAdapter(listAdapter);
}
Please let me know if I am missing any setting? Thanks in advance.
Here is one code that might help you!!
http://www.javatpoint.com/android-autocompletetextview-example
I need to output data from lines cm1 and cm2 in a ListView, every time when I press the button. Line should be shown in various TextView.
Code TEST.java:
public String cm1;
public String cm2;
public class TEST extends Activity {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
MyList = (ListView) this.findViewById(R.id.listStrings);
setListAdapter();
// button
Button setup = (Button) this.findViewById(R.id.send);
setup.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
cm1 = "cm1text";
cm2 = "cm2text";
//xxxx
}
});
}
// adapter
private void setListAdapter() {
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
R.layout.row //idknow what im must writehere to set cm1 string to cm1text tv
List.setAdapter(adapter);
}
Code TEST.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<ListView
android:id="#+id/listStrings"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1" />
<Button
android:id="#+id/send"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Send" />
</LinearLayout>
Code row.xml:
<?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"
android:orientation="vertical" >
<TextView
android:id="#+id/cm1tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="#+id/cm2tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</RelativeLayout>
Should look ListView after 2 clicks:
cm1
cm2
cm1
cm2
Maybe what you should/can do is have this;
String cm = cm1 + "\n" + cm2
Which should output;
cm1
cm2
Then you change the xml to just have one textview and the adapter code as follows;
ArrayList<String> listItems = new ArrayList<String>();
ArrayAdapter<String> aa = new ArrayAdapter<String>(this, R.layout.row, R.id.textViewCM, listItems);
yourListView.setAdapter(aa);
Then, whenever you press the button;
// ...code to initialise/change cm
listItems.add(cm);
aa.notifyDataSetChanged(); // notifies listView to update it's view
That should do what you're after unless you've got to have the two individual textViews, in which case, you'll need to write a custom adapter, I've done a bit of a tutorial on my website if you follow that link.
I have problem with displaying data in my listview. it's not displaying vertically.
here's my code:
private ListView lv;
private ArrayList<String> results = new ArrayList<String>();
#Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.meal_result);
BreakFastLog info = new BreakFastLog(this);
info.open();
String data1 = info.getMealNameData();
//String data2 = info.getServingData();
results.add(data1);
lv = (ListView) findViewById (R.id.lvBF);
lv.setAdapter(new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1, results));
lv.setTextFilterEnabled(true);
info.close();
}
and my xml
<?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" >
<ListView
android:id="#+id/lvBF"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
What's wrong with this? please help me figure out what makes it displayed horizontally.
Here's the screenshot:
After gone through your code,
You have a only one String value String data1 = info.getMealNameData();
in your ArrayList<String> results. And results is added to your List Adapter.
So only one row displayed in your ListView.
So You have to either make a String[] for all user Inputs instead of your one String data1 and pass that String[] to your List Adapter.
Update:
String data1 = info.getMealNameData();
String[] inputData = data1.split(" ");
lv.setAdapter(new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1, inputData ));
Try <RelativeLayout> in your xml instead of <LinearLayout>. And add this to your listview
<ListView
android:id="#id+/yourListViewid"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dip"
android:layout_marginRight="5dip"
android:layout_alignParentTop="true" >
</ListView>