android-custom-view

How to display multiple number of TextViews inside each row in ListView?

烈酒焚心 提交于 2020-01-03 13:00:17
问题 I am creating a Help page in which I have a set of questions and answers. These questions and answers have different styles. Here is the xml file, which describes the layout of a question & answer set : <?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="wrap_content" android:orientation="vertical" android:layout_gravity="center"> <TextView android:text="@string/Help_first

Android more complex ListView tutorial [closed]

喜夏-厌秋 提交于 2020-01-02 15:45:10
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 4 years ago . I've just started out coding for Android but am struggling to get my head around listviews. For example I need to understand how I can show another listview when clicking on an item in the first listview. Also how I can display a textview when clicking on an item in a listview. If anyone knows of any good

how to set a onclicklistener for button inside the listview in android?

|▌冷眼眸甩不掉的悲伤 提交于 2020-01-02 14:58:30
问题 I have a listView having a button and a textView. How can I set onclicklistener for the button inside the listView? Code Given below: ListView.xml: ListView lv1 = (ListView)popupView.findViewById(R.id.listView1); listviewAdapter adapter = new listviewAdapter(Order_page.this, alist); lv1.setAdapter(adapter); ListviewAdapter Class is as follows: public class listviewAdapter extends BaseAdapter { public ArrayList<HashMap<String, String>> list; Activity activity; public listviewAdapter(Activity

how to set a onclicklistener for button inside the listview in android?

删除回忆录丶 提交于 2020-01-02 14:58:28
问题 I have a listView having a button and a textView. How can I set onclicklistener for the button inside the listView? Code Given below: ListView.xml: ListView lv1 = (ListView)popupView.findViewById(R.id.listView1); listviewAdapter adapter = new listviewAdapter(Order_page.this, alist); lv1.setAdapter(adapter); ListviewAdapter Class is as follows: public class listviewAdapter extends BaseAdapter { public ArrayList<HashMap<String, String>> list; Activity activity; public listviewAdapter(Activity

GestureDetector.onTouchEvent(MotionEvent e) calling onLongPress on all gestures

旧城冷巷雨未停 提交于 2020-01-02 09:55:45
问题 I have a custom view on which I want to set long click listener. I am using following code to set the same. final GestureDetector gestureDetector = (new GestureDetector(new GestureDetector.SimpleOnGestureListener() { public void onLongPress(MotionEvent e) { Log.e("test", "Long press detected"); } })); public boolean onTouchEvent(MotionEvent event) { return gestureDetector.onTouchEvent(event); } The problem is on all gestures whether it is a single tap, double tap onLongPress is getting called

android: how to add children from an xml layout into a custom view

坚强是说给别人听的谎言 提交于 2020-01-02 01:18:29
问题 In my xml layouts I have a custom view in which i will put some children like: <com.proj.layouts.components.ScrollLayout android:id="@+id/slBody" android:layout_width="700dp" android:layout_height="400dp"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="child1"/> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="child2"/> <TextView android:layout_width="wrap_content" android:layout_height="wrap

Should I call super() or call this() for android custom view constructors?

强颜欢笑 提交于 2020-01-02 00:58:10
问题 When creating a custom view, I have noticed that many people seem to do it like this: public MyView(Context context) { super(context); // this constructor used when programmatically creating view doAdditionalConstructorWork(); } public MyView(Context context, AttributeSet attrs) { super(context, attrs); // this constructor used when creating view through XML doAdditionalConstructorWork(); } private void doAdditionalConstructorWork() { // init variables etc. } My problem with this is that it

ID of the child views in a custom view are same in Android

ⅰ亾dé卋堺 提交于 2020-01-01 19:23:17
问题 I have a custom view ValueSelectorView which contains two buttons to increment and decrement value and an EditText to display that value. In my activity, I am using this view three times. My concern here is with the child views that their id is always the same when checked in logs. Due to this, the resultant value comes out to be incorrect. I have looked over on StackOverflow and found out that some of them have faced the same issue and they are trying to solve it by manually altering the id

PorterDuff masking leaves opaque black background

淺唱寂寞╮ 提交于 2020-01-01 19:20:55
问题 I'm trying to mask a FrameLayout with a mask defined as a nine patch. However, although it works fine on 5.0+ on older versions (such as 4.4.4), the patch leaves an opaque black background. Is there anything that can be done to avoid this other than drawing to an off screen bitmap before rendering to the screen or reverting to software layers? public class MaskedLayout extends FrameLayout { private final static PorterDuffXfermode DST_IN = new PorterDuffXfermode(PorterDuff.Mode.DST_IN);

Android Map API V2 set Custom InfoWindow Position

时光怂恿深爱的人放手 提交于 2020-01-01 19:04:35
问题 I'm using InfoWindowAdapter for all the markers on my Map (Api v2). All the Markers are well visible.. The issue is that My Custom InfoWindow is having size about 500px * 300px. When I'm touching any Points on the Map its being set to Center of screen so the InfoWindow is being cropped from Top.. My requirement is to auto adjust as per Info Window Size. Please have a look at snaps. 回答1: Override the default behaviour of OnMarkerClickListener . call marker.showInfoWindow() calculate position