我正在尝试使用新的RecyclerView,但我找不到一个RecyclerView不同类型的行/卡片视图被夸大的例子.
随着ListView我覆盖getViewTypeCount和getItemViewType,用于处理不同类型的行.
我应该像"旧"方式那样做,还是应该做点什么LayoutManager?我想知道是否有人可以指出我正确的方向.因为我只能找到一种类型的例子.
我想要一张略有不同卡片的清单.或者我应该只使用一个scrollView与cardViews它里面......度过,即使没有适配器和recyclerView?
绿色来自哪里?我已经尝试更改accentColor属性,该属性适用于应用程序的其他部分,但不在此处.
来自Lollipop的应用程序的屏幕截图.
我怎样才能改变颜色:
也许是未来的一些提示......你是怎么发现的?我一直在遇到所有这些令人困惑的颜色/造型问题.是否有某种列表告诉我,我需要为某个组件覆盖哪个默认颜色或属性?
我试图了解如何使用listfragments和自定义适配器.所以我构建了这个小例子,我想知道在哪里可以将listview的分隔符设置为null.
我找到了不同的方法: - android:dividerHeight ="1dip" - android:divider ="@ android:color/transparent"但是我没有带有listview的XML布局
我也看到了类似listview.setDivider(null)的东西,但由于使用了listfragments,我不知道在我的代码中我可以在哪里使用该方法.
我的代码:
listview_item_row.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<ImageView
android:id="@+id/ivCountry"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_launcher"
android:layout_weight="1"/>
<TextView
android:id="@+id/tvCountry"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:gravity="center_vertical"
android:text="TextView"
android:layout_weight="4" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
CountryList类
public class CountryList extends ListFragment {
Country[] countries2 = new Country[]
{
new Country("Netherlands"),
new Country(R.drawable.bas,"Basque Country")
};
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
CountryAdapter adapter = new CountryAdapter(inflater.getContext(),R.layout.listview_item_row,countries2);
setListAdapter(adapter);
getListView().setDivider(null);
return super.onCreateView(inflater, container, savedInstanceState);
}
Run Code Online (Sandbox Code Playgroud)
我的CountryAdapter
public class CountryAdapter extends ArrayAdapter<Country>{ …Run Code Online (Sandbox Code Playgroud) android android-adapter android-fragments android-listfragment
如何填充已经位于自定义适配器行内的列表视图。这是正确的方法吗?
我有一个组织对象。而且这个组织可以有更多的联系。
例如,我想创建一个布局,顶部是组织名称,然后是其下的联系人名称。
获取组织对象并将其放入我的自定义适配器并显示名称没有问题。但是如何在该行布局中填充列表视图?我并没有真正获得自定义适配器内的新 ArrayAdapter 构造函数的上下文参数。它需要什么?
public class ContactAdapter extends ArrayAdapter<Organization> {
Context context;
int layoutResourceId;
ArrayList<Organization> data = null;
public ContactAdapter(Context context, int layoutResourceId, ArrayList<Organization> data) {
super(context, layoutResourceId, data);
this.context = context;
this.layoutResourceId = layoutResourceId;
this.data = data;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View row = convertView;
OrganizationHolder holder = null;
if (row == null) {
LayoutInflater inflater = ((Activity)context).getLayoutInflater();
row = inflater.inflate(layoutResourceId, parent,false);
holder = new OrganizationHolder();
holder.tvOrgName = (TextView)row.findViewById(R.id.tvOrgName);
holder.LvContacts …Run Code Online (Sandbox Code Playgroud) android android-arrayadapter android-layout android-listview
我在打字稿和 webpack 2 配置文件的语法方面遇到问题:
javascript 等效项是:
switch (process.env.BUILD_ENV) {
case 'live':
module.exports = require('./config/webpack.live');
break;
case 'debug':
module.exports = require('./config/webpack.debug');
break;
default:
module.exports = require('./config/webpack.doesntexist');
}
Run Code Online (Sandbox Code Playgroud)
Webpack 2 需要一个 TS 配置文件,所以我尝试将这部分更改为:
switch (process.env.BUILD_ENV) {
case 'live':
export * from './config/webpack.live';
break;
case 'debug':
export * from './config/webpack.debug';
break;
default:
export * from './config/webpack.doesntexist';
}
Run Code Online (Sandbox Code Playgroud)
我收到错误消息:“导出声明只能在模块中使用”。但我不清楚这意味着什么。我怎样才能在打字稿中纠正这个问题?或者这不是在 webpack 2 中构建配置的方式?