layout-inflater

Unresolved reference: LAYOUT_INFLATER_SERVICE inside onBindViewHolder

半世苍凉 提交于 2019-12-13 03:56:06
问题 Inside OnBindViewHolder of my RecyclerView Adapter , I got multiple items. One of those (ITEM_TRATAMENTOS) got a setOnClickListener which has the purpose of create an LinearLayout when I click in an button (add_field_btn). The problem is that the only argument of getSystemService is unresolved ( Context.LAYOUT_INFLATER_SERVICE ). In ViewPagers it works fine, but inside OnBindViewHolder, it's not the case. ITEM_TRATAMENTOS ->{ val viewHolderTratamentos = holder as ViewHolderItemTratamentos

Adding custom View to LinearLayout dynamicly does not work

坚强是说给别人听的谎言 提交于 2019-12-13 02:41:39
问题 I have a layout like this: <?xml version="1.0" encoding="utf-8"?> <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/recipe_coordinator_layout" android:layout_width="match_parent" android:layout_height="match_parent"> <!-- Scroll View Layout --> <ScrollView android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true"> <!-- Main Layout--> <RelativeLayout android:layout_width=

LayoutInflater doesn't seem to be linked with id in layout

南笙酒味 提交于 2019-12-12 17:32:07
问题 I am completely lost with this LayoutInflater . I am trying to link items in code with items located in a remote layout. I have tried three different versions of the inflater creation. None of them work. However, this version seems to be the most widely used. Here is a snippet of the inflater garble: setContentView(R.layout.browse); LayoutInflater li = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE); final ImageButton editBrowseButton = (ImageButton) li.inflate(R

Occasional Binary XML file line #XX: Error inflating class <unknown>

雨燕双飞 提交于 2019-12-12 12:11:53
问题 I have a main activity, that holds the main menu. This menu has an option to start a second activity, which is a SurfaceView descendent. I'm getting this error several times, but not always. I need to perform the process of calling the second activity via the first activity's menu button, and then returning to the first activity. Eventually (Usually on the 7th repetition), the error happens when the 2nd. activity is being launched. Whitout the debugger, the phone screen becomes black and is

findViewById returns null in custom View after inflate

时光怂恿深爱的人放手 提交于 2019-12-12 10:54:56
问题 I have a custom RelativeLayout and I inflate an xml res file in it. This works fine if I use the custom layout in an xml file and set it as contentview, but if I try to add it in the code with new LocationItem(this) and addChild() the findViewById method always returns null in the constructor of the custom RelativeLayout . Here is the code: public class LocationItem extends RelativeLayout { private String parcelType; private int countIntoBox, countFromBox; private RelativeLayout

App crashing when using fragments

人盡茶涼 提交于 2019-12-12 10:47:06
问题 Im working with fragments and.. Ive got a problem in my code that I just cant find. The logcat points at this piece of code, in one of my fragments: @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { return inflater.inflate(R.layout.activity_main, container, false); } My main class (the FragmentActivity): import android.app.Activity; import android.os.Bundle; import android.support.v4.app.Fragment; import android.support.v4.app

Is it recommended to check view for null with every findViewById call?

≯℡__Kan透↙ 提交于 2019-12-12 08:35:25
问题 When inflating an element with findViewById , Android Studio always warns me that my inflated view may return null View v = inflater.inflate(R.layout.fragment_photo_gallery, container, false); and suggests I do something like surround with my statement with a null check: if (v != null) { mGridView = (GridView)v.findViewById(R.id.gridView); } Is it recommended to always do the mentioned null check before inflating an element? EDIT : Adding lint pictures 回答1: You can ignore this warning and

Out of Memory error after using app for more than 5-10 mins

社会主义新天地 提交于 2019-12-12 06:37:03
问题 I've been getting following out of memory issue due to layout inflater when i use my app for little longer than 7-8 minutes. I have checked through many questions in stackoverflow but have not been able to find a good solution. I tried 'android:largeHeap="true"' too, but it seems to create more problem than solve this. The Fragment that contains the listview where i have loaded large chunk of item details which is usually causing outOfMemory error is as follows: @Override public View

NullPointerException in getView Of Adapter extends BaseAdapter

为君一笑 提交于 2019-12-12 04:47:52
问题 I am populating listview for search in tabwidget.My list contain an image and textview.Without TabWidget it works fines but in TabWidget it gives error .I have error in getview My locat is 08-07 16:24:44.300: E/AndroidRuntime(20166): FATAL EXCEPTION: main 08-07 16:24:44.300: E/AndroidRuntime(20166): java.lang.NullPointerException 08-07 16:24:44.300: E/AndroidRuntime(20166): at com.example.project.SearchDictionaryActivity$MyCustomAdapter.getView(SearchDictionaryActivity.java:392) 08-07 16:24

dynamically name textview after inflating android

狂风中的少年 提交于 2019-12-12 02:29:04
问题 I m inflating 4 linear layouts multiple times in a scroll view. Each layout has a title in its header. The code snippet is given below. for(int j=0;j<qType.length;j++) { LinearLayout.LayoutParams siz = new LinearLayout.LayoutParams(width, height);; if(qType[j]==0) { view1 = getLayoutInflater().inflate(R.layout.layout1, main_layout,false); siz = new LinearLayout.LayoutParams(width, height/3); } else if(qType[j]==1) { view1 = getLayoutInflater().inflate(R.layout.layout3, main_layout,false); siz