listview

Change item background color in simple listView

夙愿已清 提交于 2020-02-06 08:08:04
问题 I would like to change an item background color when clicked, in a simple listView. Here's my code: boolean[] selectedItem = new boolean[listElement.length] final ArrayList<String> list1 = new ArrayList<>(); Collections.addAll(list1, listElement); final ListView mylist = (ListView) findViewById(R.id.listView); final ArrayAdapter<String> adapter = new ArrayAdapter<>(context, android.R.layout.simple_list_item_1, list1); mylist.setAdapter(adapter); mylist.setOnItemClickListener(new AdapterView

How to make ListView to refresh after every 5 sec when data come from a server

笑着哭i 提交于 2020-02-06 07:28:29
问题 I have ListView which have data . Data come from server and I want the ListView to update after every 5 sec. How to do this? I am new to android development. Please help me. Here is my code... protected void showList() { try { JSONObject jsonObj = new JSONObject(myJSON); peoples = jsonObj.getJSONArray(TAG_RESULTS); for (int i = 0; i < peoples.length(); i++) { JSONObject c = peoples.getJSONObject(i); String data = c.getString(TAG_DATA); final String dataaaa = rcdata.getText().toString().trim()

How to make ListView to refresh after every 5 sec when data come from a server

為{幸葍}努か 提交于 2020-02-06 07:28:05
问题 I have ListView which have data . Data come from server and I want the ListView to update after every 5 sec. How to do this? I am new to android development. Please help me. Here is my code... protected void showList() { try { JSONObject jsonObj = new JSONObject(myJSON); peoples = jsonObj.getJSONArray(TAG_RESULTS); for (int i = 0; i < peoples.length(); i++) { JSONObject c = peoples.getJSONObject(i); String data = c.getString(TAG_DATA); final String dataaaa = rcdata.getText().toString().trim()

How/where in the code to detect wether in ListFragment's ListView all items are visible?

拟墨画扇 提交于 2020-02-06 06:56:41
问题 I am trying to change the ActionBar's action depending on wether all list items are visible (there's less items that fit to the screen => show "Add item" action | there are some items invisible => show "Search" action) What method of ListFragment should I override in order to be able to use getListView().getLastVisiblePosition() and get not -1? This is the code from my ListFragment, but in onCreateOptionsMenu lv.getLastVisiblePosition() always returns -1. @Override public void

How/where in the code to detect wether in ListFragment's ListView all items are visible?

被刻印的时光 ゝ 提交于 2020-02-06 06:56:38
问题 I am trying to change the ActionBar's action depending on wether all list items are visible (there's less items that fit to the screen => show "Add item" action | there are some items invisible => show "Search" action) What method of ListFragment should I override in order to be able to use getListView().getLastVisiblePosition() and get not -1? This is the code from my ListFragment, but in onCreateOptionsMenu lv.getLastVisiblePosition() always returns -1. @Override public void

Android nested listview adapter adding only first element

无人久伴 提交于 2020-02-06 05:40:46
问题 My purpose is a list in a list like this: -alllist-------- ----row--------- ----row--------- -----(list)----- -------textview -------textview ---row--------- -----(list)---- ..... MainAdapter Class is working fine with other elements but PlaceAdapter is adding only the first (or last, I couldn't figure) item to the 'nested' list. What is the problem? MainAdapter: @Override public View getView(int position, View convertView, ViewGroup parent) { PlaceHolder placeHolder = null; if (convertView =

best native component to use for separate listview in android

♀尐吖头ヾ 提交于 2020-02-05 07:24:24
问题 Hi I need to have a list view which is separated by date which native component i should use in android?can zou help me mazbe with some links, how to do it.I have an list activity coded, and working fine.thanks or maybe some dropdown box if is better i mean sthink like that: 回答1: An ExpandableListView with custom group and child layout and disabled collapsing would be the simplest solution for you. The list of groups would be the dates, the list of children would be the childLists (for each

Two arrays in one TextView in a ListView

烈酒焚心 提交于 2020-02-05 06:20:47
问题 I have a question that I would love to get an answer on. I have two arrays, let's say: String[] name = {"Name Nameson", "Second Name"}; String[] number = {"111 11 111", "222 22 222"}; I want my ListView to have two TextViews into one item.(I tried to illustrate this with a picture). I manage to get f.ex. my name array into the listview with a simple lv.setAdapter(new ArrayAdapter<String>(this, R.layout.single_name, name)); I have my main.xml with my ListView in it, single_name.xml and single

I have two activity.I want to Send the data from second activity to previous activity.First activity have custom Listview

纵然是瞬间 提交于 2020-02-04 09:27:09
问题 I have two activity.I wanna Send the data from second activity to previous activity.First activity have custom List view and bean class.When was i click on second activity,Fist activity fetch the data in form of String.My problem is how i will display the fetch data on custom listview My First actvity is.. package com.firstchoicefood.phpexpertgroup.firstchoicefoodin; import android.app.ActionBar; import android.app.ProgressDialog; import android.content.Intent; import android.content.res

android popup window not displaying

社会主义新天地 提交于 2020-02-04 05:54:28
问题 I am creating a popup window with a listview. In the listview each row contains a textbox and radio button but the popup window not displaying. I can't figure out the mistake. This is the code. import java.util.List; import java.util.Vector; import android.app.Activity; import android.app.AlertDialog; import android.content.Context; import android.content.SharedPreferences; import android.graphics.Typeface; import android.os.Bundle; import android.preference.PreferenceManager; import android