Tag: layout inflater

Android应用的插件架构?

这个问题已经转移到https://softwarerecs.stackexchange.com/questions/27841/plugins-architecture-for-an-android-app 我想实现一个开放源码应用程序的插件系统,因为它已经变得非常庞大,只有less数用户需要的许多function。 发布不同的应用程序并不是一个好的解决scheme,因为用户A需要feature7和feature24,而用户B需要f​​eature39和feature24。 我在哪里可以find一个插件架构的好例子? 这是我想要一个插件能够做到的: 重新定义特定屏幕的布局( 加载压缩的XML ?) 重新定义一个类的方法( load dex class ?, AOP ?) 例如,其中一个插件必须在特定的屏幕上添加一个button,然后单击该button将增加应用程序数据库中的值。 据我所知,这对内容提供商和意图来说是不可行的。 我想避免使核心应用程序的代码复杂到处都是大量的钩子。 插件的forms可以是SD卡上的文件,应用程序或其他任何东西。

LayoutInflater attachToRoot参数是什么意思?

LayoutInflater.inflate文档并不完全清楚attachToRoot参数的用途。 attachToRoot :膨胀的层次结构是否应该附加到根参数? 如果为false,则root仅用于为XML中的根视图创buildLayoutParams的正确子类。 有人可以请详细解释一下,特别是根视图是什么,也可以显示true值和false值之间的行为变化的例子?

避免传递null作为视图根(需要parsing膨胀布局的根元素上的布局参数)

为root工作室传递null给了我这个警告: 避免传递null作为视图根(需要parsing膨胀布局的根元素上的布局参数) 它在getGroupView显示一个空值。 请帮忙。 public class ExpandableListAdapter extends BaseExpandableListAdapter { private Context _context; private List<String> _listDataHeader; // header titles // child data in format of header title, child title private HashMap<String, List<String>> _listDataChild; public ExpandableListAdapter(Context context, List<String> listDataHeader, HashMap<String, List<String>> listChildData) { super(); this._context = context; this._listDataHeader = listDataHeader; this._listDataChild = listChildData; } @Override public […]

在DialogFragment中为AlertDialog夸大自定义视图的问题

我正在尝试在DialogFragment使用自定义视图创build一个AlertDialog 。 这个视图必须从xml中夸大。 在我的DialogFragment类中,我有: @Override public Dialog onCreateDialog(Bundle savedInstanceState) { return new AlertDialog.Builder(getActivity()) .setTitle("Title") .setView(getActivity().getLayoutInflater().inflate(R.layout.dialog, null)) .setPositiveButton(android.R.string.ok, this) .setNegativeButton(android.R.string.cancel, null) .create(); } 我已经尝试其他通胀方法.setView()如: .setView(getActivity().getLayoutInflater().inflate(R.layout.dialog, (ViewGroup) getView(), false)) 和 .setView(getActivity().getLayoutInflater().inflate(R.layout.dialog, (ViewGroup) getTargetFragment().getView(), false)) 在显示此对话框的片段中设置目标片段之后。 所有这些尝试膨胀我的自定义视图结果在以下例外: E/AndroidRuntime(32352): android.util.AndroidRuntimeException: requestFeature() must be called before adding content E/AndroidRuntime(32352): at com.android.internal.policy.impl.PhoneWindow.requestFeature(PhoneWindow.java:214) E/AndroidRuntime(32352): at com.android.internal.app.AlertController.installContent(AlertController.java:248) E/AndroidRuntime(32352): at android.app.AlertDialog.onCreate(AlertDialog.java:314) E/AndroidRuntime(32352): at android.app.Dialog.dispatchOnCreate(Dialog.java:335) […]

在创build自己的自定义适配器时,getView()方法如何工作?

我的问题是: LayoutInflater的function究竟是什么? 为什么我读过的所有文章检查convertview是否为空? 这是什么意思,当它是空的,这是什么意思,当它不是? 这个方法接受的父参数是什么?

如何使用布局膨胀一个视图

我有一个用XML定义的布局。 它还包含: <RelativeLayout android:id="@+id/item" android:layout_width="fill_parent" android:layout_height="wrap_content" /> 我想膨胀这个RelativeView与其他XML布局文件。 根据情况我可以使用不同的布局。 我应该怎么做? 我正在尝试不同的变化 RelativeLayout item = (RelativeLayout) findViewById(R.id.item); item.inflate(…) 但是没有一个能正常工作。