android-custom-view

NullPointer Exception in listview,creating separate layout for listitems?

与世无争的帅哥 提交于 2019-12-14 03:28:17
问题 I created a listview that contains two types of items either text or image.But i am getting nullpointer exception only on when i scrolling down. my adapter's code is this. public class ListViewAdapter extends BaseAdapter { ArrayList<ListModel> myList = new ArrayList<ListModel>(); LayoutInflater inflater; Context context; private static final int TYPE_ITEM1 = 1; private static final int TYPE_ITEM2 = 2; public ListViewAdapter(Context context, ArrayList<ListModel> myList) { this.myList = myList;

Click event not working on button in listview item

你离开我真会死。 提交于 2019-12-14 02:42:08
问题 I am using a custom Listview with Custom views as list elements, each list item is a separate Custom view . The problem which I am facing is , click event on button in 1st item of ListView is not getting fired when we click on it. After clicking on it if we click somewhere else in the screen the click event get fires. I am not able to find the solutions for it and I am struggling with it. Any help will be highly appreciated. Updated with code: Here is the getview method public override View

MarginLayoutParams.setMargins() is not working?

橙三吉。 提交于 2019-12-14 01:27:53
问题 Here's the thing: I want to add some images programmatically. The images should have to have a topMargin of 5dip except for the first image, in a LinearLayout with a vertical orientation manner. below the code segment: LinearLayout body = (LinearLayout) findViewById(R.id.body); for (int i = 1; i <= 4; i++) { ImageView img = new ImageView(this); MarginLayoutParams lp = new MarginLayoutParams(-2, -2); img.setImageResource(R.drawable.image); if (i != 1) { lp.setMargins(0, 5, 0, 0); } img

android: MultiAutoCompleteTextView style like gmail

痴心易碎 提交于 2019-12-14 01:26:08
问题 I want create custom MultiAutoCompleteTextView like gmail app: I create custom view and extend to MultiAutoCompleteTextView and use Span , but I have problem, if there is not enough room for text and image then and span have (space) then view split them and there is my code for custom view: public class CustomMultiAutoCompleteTextView extends MultiAutoCompleteTextView { @Override public void setTokenizer(Tokenizer t) { super.setTokenizer(t); } public CustomMultiAutoCompleteTextView(Context

How to get width and height of resized custom view , before it is drawn

↘锁芯ラ 提交于 2019-12-13 19:43:11
问题 In my custom View .xml , i have defined width and height as w = 600dp , h = 700dp . Now i know getMeasuredHeight() / getMeasuredWidth() give values of width and height after view is drawn and they may differ from what i've given in .xml file , is there a workaround to get getMeasuredHeight() and getMeasuredWidth() values before view is actually drawn on layout, without use of onMeasure() ? And How to calculate changed dp sizes in different screens ? like my 600h*700w when run on emulator

How can i handle setOnScrollListener for Custom View android

左心房为你撑大大i 提交于 2019-12-13 19:17:18
问题 I have a list view where i created custom adapter. I am displaying a button when i swipe right, so i have setOnTouchListener. My problem is i want to remove the button and display another button when i start scrolling. Following is the adapter for holding the view public static final class TransactionAddDropViewHolder { public View moveUpButton = null; public View moveDownButton = null; public View withdrawButton = null; public View reviewButton = null; public View approveButton = null;

Need a ViewGroup(Customised) for Different Rowheights with two columns in Android

做~自己de王妃 提交于 2019-12-13 17:14:36
问题 I have infinite number of items. Want to display them in two columns as a GridView with lazy loading. I tried it with GridView, which is displaying all items in a row with the same height. But want it to be adjusted according to the item height as in the attached image. If anyone have any idea or any of u have implemented this with some customized View. Please share it across. Thanx in advance. 回答1: New answer Look at the RecyclerView . The RecyclerView replaces ListView and is designed to be

How do you pass the gravity attribute via xml for a custom view?

妖精的绣舞 提交于 2019-12-13 14:16:58
问题 I'm trying to figure out how to pass android:gravity via xml for a custom view. The solution posted here (https://stackoverflow.com/a/3441986/413254) says to add the android:gravity attribute to the other attr's. When I do this, I end up with a warning saying: /Users/greg/dev/company/mobile/my_app/app/src/main/res/values/colors.xml Error:Attribute "android:gravity" has already been defined Error:Execution failed for task ':app:processStagingDebugResources'. com.android.ide.common.internal

How to check which editext textwatcher listener is called in dynamically created edittext

大兔子大兔子 提交于 2019-12-13 12:48:02
问题 I am able to add Textwatcher listener for dynamically created Edittext so basically I'll check the first editext ontextchanged if there is any value create another edittext and so on.How can check which edittext is called in the listener. I have checked couple of links how-to-use-single-textwatcher-for-multiple-edittexts but the Ids are fixed in this case. Code: public class MainActivity extends Activity { EditText textIn; Button buttonAdd; LinearLayout container; Button buttonShowAll; static

Edit Text in custom List View Loses Value on Scroll

女生的网名这么多〃 提交于 2019-12-13 12:22:06
问题 I know it's duplicate question, but I didn't find proper answer. In my custom list-view having a two textview and one Editext, when I inserted a value in edit text and scroll then I loss value of edited text. And when I pass string value for an adapter through list adapter then it will show blank edit text. Here my Adapter code: class CreateAdapter extends ArrayAdapter<String> { String[] strItecode=null; String[] strItem; String[] strQuantity,text; Context context; int temp; CreateAdapter