android-listview

Should the ActionBar be handled on Fragments or on the Activity?

僤鯓⒐⒋嵵緔 提交于 2020-01-06 01:46:34
问题 I am making a shopping list app, and I have two Fragments , a ProductListFragment and a ShoppingListFragment . I have ActionBar buttons to add elements to the List on ProductListFragment . My question is, should I handle these buttons on the Fragment or on the Activity? 回答1: You should allow your Activity to handle the events of your fragments. This allows you flexibility in your design so that you can reuse your fragments in other Activities down the line. Here is a great example of how to

How to get a ListView's child view at specific index

风流意气都作罢 提交于 2020-01-05 13:32:32
问题 I need to dynamically change the background color of a child view of a ListView at a specific index. So I need to get the view first before applying the background. I have tried the following. getViewAt(int index) - this is not applicable to ListView . getChildAt(int index) - this gives runtime NPE error A Google search returns irrelevant results. Please help me out. Thank you. 回答1: I figured out how to do this. I really think that one should not have to post code and logcat for a question

How do I use ListView as one of the children of a ScrollView

怎甘沉沦 提交于 2020-01-05 12:11:40
问题 I have read a number of literatures that say not to do this. But they have yet to offer an alternative solution. The question seems to come up a lot, though. Here is my problem. I want my main layout to be scrollable (this is because it will have more views than can fit the screen). My main layout is a vertical LinearLayout. So for now I have it inside a ScrollView. one of the many children of my LinearLayout is a ListView (shows 3 items, user scrolls the ListView for more). You can image the

ListView not getting updated on calling notifyDataSetChanged()

China☆狼群 提交于 2020-01-05 12:11:07
问题 i want to add data into the listview when pressing the button. but it is not getting updated pressing the button dont know how it is not getting worked. Please help me. here is the code below @SuppressLint("NewApi") public class Messanger extends Activity { ArrayAdapter<String> adapter; ListView output; EditText box; String msg[]; Button btn; int counter=0; ArrayList<String> listItems; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);

MPAndroidChart Scatterchart in ListView

梦想与她 提交于 2020-01-05 09:47:59
问题 I am using the MPAndroidChart library. I have multiple scattercharts in a ListView. Every chart contains 365 xvalues (every day of the year). The yvalues vary from 1 to 5. The height of the charts is 150dp. I would like to be able to zoom in, so I can see every single day. But when I zoom in, the yvalues get out of range of the chart. Is there a way to keep the yvalues within range of the chart? I tried it with the next settings: holder.chart.setTouchEnabled(true); holder.chart.setDragEnabled

MPAndroidChart Scatterchart in ListView

穿精又带淫゛_ 提交于 2020-01-05 09:42:39
问题 I am using the MPAndroidChart library. I have multiple scattercharts in a ListView. Every chart contains 365 xvalues (every day of the year). The yvalues vary from 1 to 5. The height of the charts is 150dp. I would like to be able to zoom in, so I can see every single day. But when I zoom in, the yvalues get out of range of the chart. Is there a way to keep the yvalues within range of the chart? I tried it with the next settings: holder.chart.setTouchEnabled(true); holder.chart.setDragEnabled

Fragments are not loaded from Navigation Drawer Click Listener

不羁的心 提交于 2020-01-05 09:30:15
问题 Android OnItemClickListener is not working. I have already researched some of the previous similar questions I could not find any solution to my problem. I find Log.d("TAG", "Item Click Working"); in the Logcat but I am not able to open a new fragment. I am attaching the code below. **MainActivity** import java.io.UnsupportedEncodingException; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import org.json.JSONException; import org.json.JSONObject; import android

how to scroll listview to specific position in android programmatically

自闭症网瘾萝莉.ら 提交于 2020-01-05 07:38:15
问题 I try to make listview to scroll to position , i have tried all possible functions but all not work for more explanation of code firstly : i put markers on map then call list adapter secondly L if user click marker on map the list view should show the selected position as marker clicked private void Putting_places_on_Map(final List<PlaceModel> Places) { // TODO Auto-generated method stub for (int i = 0; i < Places.size(); i++) { LatLng place_loc = new LatLng(Double.parseDouble(Places.get(i)

sqlite row ids not matching listview - ANDROID

被刻印的时光 ゝ 提交于 2020-01-05 07:37:56
问题 This may turn out as a lame question, but I am a beginner and don't seem to understand the behavior of my app. I have a SQLite data base, and a list view in the main activity. In the list view I display the List no.(row id) and other details. and on pressing the list item, a new activity opens up which displays the details in a textview and has 2 image buttons for delete and sync. The app works just fine until I delete any entry. Once I delete any entry the row id on the listview doesn't seem

Multiple Horizontal List View

a 夏天 提交于 2020-01-05 07:14:17
问题 In my activity, I have three horizontal list views. Each list view is different. I'm having difficulty trying to get a certain layout to work: I want to have multiple lists on a page; each list does not have to be scrollable, but should be shown completely. The page itself should be able to scroll (with the lists in it), if the total content is longer than the screen, like the Allrecipes.com Dinner Spinner app. 回答1: Add your scrollviews to a listview. You can create a listadapter which