layout-inflater

inflate a button using xml to style

ぐ巨炮叔叔 提交于 2019-12-11 04:24:16
问题 Trying to inflate a Button code: LinearLayout ll = (LinearLayout)this.getLayoutInflater().inflate(R.layout.assets, null); Button btn = (Button)ll.getChildAt(0); R.layout.assets (assets.xml): <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:id="@+id/main" android:layout_height="match_parent" android:weightSum="1" android:padding="50px"> <Button android:text="Button" android:layout_width=

Why does a ProgressBar's id need to be unique?

旧城冷巷雨未停 提交于 2019-12-11 04:05:03
问题 I declared an empty LinearLayout to which in my onCreate method I call a function that has a loop that repeats five times to inflate another layout and add it to my LinearLayout. private void setupList() { LayoutInflater layoutInflater = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE); LinearLayout itemList = (LinearLayout) findViewById( R.id.itemList ); itemList.removeAllViews(); for ( Category category :: categories ) { View rowView = layoutInflater.inflate(R.layout

Android: Getting the View added with LayoutInflator

寵の児 提交于 2019-12-11 03:45:37
问题 Java or C# answers are fine (we use MonoDroid) I successfully add a control to a LinearLayout with: LayoutInflater _inflatorservice = (LayoutInflater)this.GetSystemService(Context.LayoutInflaterService); var viewContainer = _inflatorservice.Inflate(Resource.Layout.ReportItImageButton, myLinearLayout); How do I then get a reference to the view just added? I add many of the same control this way so would need to get the nth item added to the layout. 回答1: This works, it gets the most recent item

Dynamically include another layout in Fragment Activity

柔情痞子 提交于 2019-12-11 01:39:37
问题 This is my Home.xml layout file <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/rellay" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:background="@drawable/placesgradient"> <Button android:id="@+id/btn2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:text="click" /> **<I want to

How to set a typeface to menu items in overflow menu on toolbar

牧云@^-^@ 提交于 2019-12-10 22:13:34
问题 I want to change the default typeface of the items of the overflow menu and set a custom typeface . I tried adding a Factory to the LayoutInflater and within the onCreateView() method I changed the TextView's typeface . But it didn't work. Here is the code(Inside onCreateOptionsMenu), getLayoutInflater().cloneInContext(this).setFactory(new LayoutInflater.Factory() { @Override public View onCreateView(String name, Context context, AttributeSet attrs) { if (name.contains("com.android.internal

Load resource (layout) from another apk

我怕爱的太早我们不能终老 提交于 2019-12-10 17:48:29
问题 I am wondering if it is possible to load a layout xml file from another apk. I know how to get access to another applications resources, but i am unsure how to load an xml if its even possible. Would I have to parse the xml if I wanted to set that layout as a view using layout inflater? Sort of like these steps... Use XmlPullParser.setInput to "load" the XML file Convert it to an AttributeSet Create a View from this AttributeSet use setContentView(View) in your Activity I guess what i am

Android: Custom Adapter with custom spinner drop down xml layout giving error

邮差的信 提交于 2019-12-10 14:54:35
问题 I have a spinner with a custom adapter that I used to set the height of the first element in the spinner drop down to zero. I do this to have a default message in my spinner (first element) without the user being able to click it, since it's not visible. package org.digitalhealthagency.elaj.util; import java.util.ArrayList; import org.digitalhealthagency.elaj.gui.R; import android.content.Context; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup;

InflateException on inflater.inflate() method call

拜拜、爱过 提交于 2019-12-10 14:06:56
问题 I keep getting an InflateException upon trying to inflate a view in my MenuAdapter class. I've surrounded the troublesome code in a try-catch block and get the error Message: link to the entire project: https://docs.google.com/file/d/0B2Iwl4UysxOMa3E5a1l2SHZwOG8/edit?usp=sharing Binary XML file line #1: Error inflating class Here is the code: package com.example.sidemenututorial; import android.content.Context; import android.view.LayoutInflater; import android.view.View; import android.view

Error inflating class de.hdodenhof.circleimageview.CircleImageView in Android version 6 marshmallow

六眼飞鱼酱① 提交于 2019-12-10 13:24:11
问题 I created an app which uses this hdodenhof CircleImageview library. My app works fine on Android 7 and 7.1 but it is crashing in lower versions such as marshmallow/Android 6. How can I solve this problem? I have read his GitHub posts but it did not solve my problem as people has asked to remove attributes from the .xml, but I didn't use these attributes. Here's my simple implementation of the CircleImageView: <de.hdodenhof.circleimageview.CircleImageView android:id="@+id/civ_requests" android

Is it possible to redefine a library's databinding resource?

别说谁变了你拦得住时间么 提交于 2019-12-10 11:14:17
问题 I am developing a library that uses Data Binding to process attributes in a Layout 's Views (I won't develop as it is irrelevant to this issue). As the applications should be able to specify their own layout, I am trying to leverage the resource prioritization mechanism: In cases where a resource ID is defined in both the application and the library, the tools ensure that the resource declared in the application gets priority and that the resource in the library module is not compiled into