- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
这是日志,此日志显示的次数与 itemView 的次数一样多。但我的应用程序仍在正常运行。
D/ViewGroup﹕ addInArray been called, this = android.support.v7.widget.RecyclerView{44dd4fc8 VFEDID 0,86-720,1140 7f0e01cc app:id/order_query_rv}call stack =
java.lang.Throwable: addInArray
at android.view.ViewGroup.addInArray(ViewGroup.java:3788)
at android.view.ViewGroup.addViewInner(ViewGroup.java:3742)
at android.view.ViewGroup.addView(ViewGroup.java:3566)
at android.view.ViewGroup.addView(ViewGroup.java:3511)
at android.support.v7.widget.RecyclerView$4.addView(RecyclerView.java:538)
at android.support.v7.widget.ChildHelper.addView(ChildHelper.java:83)
at android.support.v7.widget.RecyclerView$LayoutManager.addViewInt(RecyclerView.java:6025)
at android.support.v7.widget.RecyclerView$LayoutManager.addView(RecyclerView.java:5983)
at android.support.v7.widget.RecyclerView$LayoutManager.addView(RecyclerView.java:5971)
at android.support.v7.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1373)
at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1322)
at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:556)
at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:2673)
at android.support.v7.widget.RecyclerView.onLayout(RecyclerView.java:2971)
at android.view.View.layout(View.java:15302)
at android.view.ViewGroup.layout(ViewGroup.java:4864)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1888)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1742)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1651)
at android.view.View.layout(View.java:15302)
at android.view.ViewGroup.layout(ViewGroup.java:4864)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1888)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1742)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1651)
at android.view.View.layout(View.java:15302)
at android.view.ViewGroup.layout(ViewGroup.java:4864)
at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1160)
at android.view.View.layout(View.java:15302)
at android.view.ViewGroup.layout(ViewGroup.java:4864)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:515)
at android.widget.FrameLayout.onLayout(FrameLayout.java:450)
at android.view.View.layout(View.java:15302)
at android.view.ViewGroup.layout(ViewGroup.java:4864)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1888)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1742)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1651)
at android.view.View.layout(View.java:15302)
at android.view.ViewGroup.layout(ViewGroup.java:4864)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:515)
at android.widget.FrameLayout.onLayout(FrameLayout.java:450)
at android.view.View.layout(View.java:15302)
at android.view.ViewGroup.layout(ViewGroup.java:4864)
at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2323)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2029)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1192)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6231)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:817)
at android.view.Choreographer.doCallbacks(Choreographer.java:619)
at android.view.Choreographer.doFrame(Choreographer.java:588)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:803)
at android.os.Handler.handleCallback(Handler.java:808)
at android.os.Handler.dispatchMessage(Handler.java:103)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:5409)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit MethodAndArgsCaller.run(ZygoteInit.java:859)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:675)
at dalvik.system.NativeStart.main(Native Method)
找了半天,还是没找到解决办法。Throwable 是什么原因导致的,如何解决。
Activity
public class OrderQueryActivity extends BaseActivity implements IOrderQueryView {
@Override
protected void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.base_mains);
super.onCreate(savedInstanceState);
dealTopMenu();
this.iPresenter = new OrderQueryPresenter(OrderQueryActivity.this, new OrderQueryDao());
}
@Override
public void initView() {
super.initView();
final View contentView = View.inflate(getContext(), R.layout.layout_online_order_query, null);
this.orderQueryTitle = (LinearLayout) contentView.findViewById(R.id.order_query_title_ll);
this.addView(contentView);
this.sumNum = (TextView) contentView.findViewById(R.id.order_num_tv);
this.sumWeigh = (TextView) contentView.findViewById(R.id.order_weight);
this.sumAmount = (TextView) contentView.findViewById(R.id.order_total_amount);
this.rv = (RecyclerView) contentView.findViewById(R.id.order_query_recycler_view);
this.rv.setHasFixedSize(true);
this.rv.setLayoutManager(new LinearLayoutManager(getContext()));
}
@Override
public void setAdapterForRv() {
this.adapter = new OrderQueryAdapter(iPresenter);
this.rv.setAdapter(adapter);
}
}
xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:id="@+id/order_query_title_ll"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/gray"
android:orientation="vertical"
android:visibility="invisible">
<TextView
style="@style/online_order_query_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="4dp"
android:paddingTop="4dp"
android:text="@string/total_order_num" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:baselineAligned="false"
android:orientation="horizontal">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:orientation="horizontal"
android:paddingLeft="72dp">
<TextView
android:id="@+id/order_num_tv"
style="@style/online_order_query_title_bold"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/order_number_example" />
<TextView
style="@style/online_order_query_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/order_number_unit" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_horizontal"
android:orientation="horizontal">
<TextView
android:id="@+id/order_weight"
style="@style/online_order_query_title_bold"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/order_weight_example" />
<TextView
style="@style/online_order_query_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/weight_unit" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="right"
android:orientation="horizontal">
<TextView
android:id="@+id/order_total_amount"
style="@style/online_order_query_title_bold"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/order_total_amount_example" />
<TextView
style="@style/online_order_query_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingRight="4dp"
android:text="@string/money_unit" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
<android.support.v7.widget.RecyclerView
android:id="@+id/order_query_recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical" />
</LinearLayout>
适配器
public class OrderQueryAdapter extends RecyclerView.Adapter<OrderQueryAdapter.ViewHolder> {
private ArrayList<OrderBean> orderData;
private IOrderQueryPresenter presenter;
public OrderQueryAdapter(IOrderQueryPresenter presenter) {
this.presenter = presenter;
this.orderData = presenter.getOrderData();
}
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.query_online_order_card_item, parent, false);
return new ViewHolder(v);
}
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
OrderBean order = orderData.get(position);
holder.dealerName.setText(order.getChannelName());
holder.orderTime.setText(order.getOrderTime());
holder.orderStatus.setText(order.getOrderStatus());
holder.prodsNum.setText(order.getOrderSumNumber());
holder.prodsWeight.setText(order.getWeight());
holder.orderAmount.setText(order.getOrderSumPrice());
holder.payment.setText(order.getPayAmount());
OnDetailClickListener onDetailClickListener = new OnDetailClickListener(presenter, position);
holder.orderContentll.setOnClickListener(onDetailClickListener);
}
@Override
public int getItemCount() {
return orderData.size();
}
public static class ViewHolder extends RecyclerView.ViewHolder {
TextView dealerName, orderTime, orderStatus, prodsNum, prodsWeight, orderAmount, payment;
LinearLayout orderContentll;
public ViewHolder(View view) {
super(view);
this.dealerName = (TextView) view.findViewById(R.id.dealer_name);
this.orderTime = (TextView) view.findViewById(R.id.order_time);
this.orderStatus = (TextView) view.findViewById(R.id.order_status);
this.prodsNum = (TextView) view.findViewById(R.id.prod_count_online_order);
this.prodsWeight = (TextView) view.findViewById(R.id.prod_weight_online_order);
this.orderAmount = (TextView) view.findViewById(R.id.prod_amount_online_order);
this.payment = (TextView) view.findViewById(R.id.payment_order_online);
this.orderContentll = (LinearLayout) view.findViewById(R.id.ll_order_content);
}
}
static class OnDetailClickListener implements View.OnClickListener {
private int position;
private IOrderQueryPresenter presenter;
public OnDetailClickListener(IOrderQueryPresenter presenter, int position) {
this.presenter = presenter;
this.position = position;
}
@Override
public void onClick(View v) {
int id = v.getId();
switch (id) {
case R.id.ll_order_content:
presenter.startOrderDetail(position);
break;
}
}
}
}
项目xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="2dp"
android:layout_marginLeft="4dp"
android:layout_marginRight="4dp"
android:layout_marginTop="2dp">
<android.support.v7.widget.CardView
android:id="@+id/online_pay_card_item"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/white">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:padding="8dp">
<LinearLayout
android:id="@+id/ll_dealer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="2dp"
android:orientation="horizontal">
<TextView
android:id="@+id/dealer_name"
style="@style/online_order_query_primary_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/dealer_name" />
<TextView
android:id="@+id/order_time"
style="@style/online_order_query_primary_tv"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="end"
android:text="@string/order_time_example" />
</LinearLayout>
<ImageView
android:id="@+id/divider_one"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="@+id/ll_dealer"
android:background="@drawable/single_divider_line_black"
android:contentDescription="@string/app_name" />
<LinearLayout
android:id="@+id/ll_order_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/divider_one"
android:background="@drawable/order_detail_selector"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="2dp"
android:orientation="horizontal">
<TextView
style="@style/size14GreyText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/order_status_str" />
<TextView
android:id="@+id/order_status"
style="@style/size14GreyText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="4dp"
android:text="@string/order_status_example" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="2dp"
android:baselineAligned="false"
android:orientation="horizontal">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="left"
android:orientation="horizontal">
<TextView
style="@style/size14GreyText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/prod_num_str" />
<TextView
android:id="@+id/prod_count_online_order"
style="@style/size14GreyText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="4dp"
android:text="@string/prod_num_example" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_horizontal"
android:orientation="horizontal">
<TextView
style="@style/size14GreyText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/prod_weight" />
<TextView
android:id="@+id/prod_weight_online_order"
style="@style/size14GreyText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="4dp"
android:text="@string/weight_example" />
<TextView
style="@style/size14GreyText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/weight_unit" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="left"
android:orientation="horizontal">
<TextView
style="@style/size14GreyText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/order_amount" />
<TextView
android:id="@+id/prod_amount_online_order"
style="@style/online_order_query_primary_tv"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:paddingLeft="4dp"
android:text="@string/order_amount_example" />
<TextView
style="@style/size14GreyText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/money_unit" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
<ImageView
android:id="@+id/divider_two"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="@+id/ll_order_content"
android:background="@drawable/single_divider_line_black"
android:contentDescription="@string/app_name" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/divider_two"
android:layout_margin="4dp"
android:baselineAligned="false"
android:gravity="center_vertical"
android:orientation="horizontal">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="4dp"
android:gravity="left"
android:orientation="horizontal">
<TextView
style="@style/size14GreyText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/already_payment" />
<TextView
android:id="@+id/payment_order_online"
style="@style/online_order_query_primary_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="4dp"
android:text="@string/order_payment_example" />
<TextView
style="@style/size14GreyText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/money_unit" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="end"
android:orientation="horizontal">
<Button
android:id="@+id/payment_detail_btn"
style="@style/iBtn_listView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/mm_title_btn_right"
android:paddingLeft="24dp"
android:paddingRight="24dp"
android:text="@string/payment_detail" />
<Button
android:id="@+id/pay_online_order_btn"
style="@style/iBtn_listView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:background="@drawable/mm_title_btn_right"
android:paddingLeft="24dp"
android:paddingRight="24dp"
android:text="@string/pay_online_order" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
最佳答案
我遇到了同样的问题......
修改fragment中的代码后问题消失
来自
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
...
detailAdapter = new TitleAdapter(getChildFragmentManager(),getActivity());//remove this
...
}
上
@Override
public void onAttach(Context context) {
super.onAttach(context);
detailAdapter = new TitleAdapter(getActivity().getSupportFragmentManager (),getActivity());//add this
}
关于java.lang.可抛出的 : addInArray in RecyclerView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31244332/
来自 java docs 公共(public) FileWriter(String fileName) 抛出 IOException 抛出: IOException - 如果指定的文件存在但它是目录而
我使用以下代码将我的 .net 客户端(基于 CQL)连接到 3 节点 Cassandra 集群。我以 30 条记录/秒的速度(从 RabbitMQ)获取数据,并且它们顺利地存储在 cassandra
如果在读取文件时缺少字段,我应该捕获 NoSuchElementException。如果缺少一个字段,我只需要跳到文件的下一行。我的问题是,我在哪里实现我的 try/catch 代码来做到这一点?这是
我正在尝试使用 ASP.NET MVC 实现 OpeinID 登录。我正在尝试按照 http://blog.nerdbank.net/2008/04/add-openid-login-support-
学习使用 Java 进行 xml 解析,并且正在编写一个测试程序来尝试各种东西。所有测试 System.out.println() 都是我在控制台中所期望的,除了 childElement 返回 [n
我正在尝试使用 SwingUtilities 创建 JFrame Thread tt = new Thread(new Runnable() { public void run
关闭。这个问题是not reproducible or was caused by typos .它目前不接受答案。 这个问题是由于错别字或无法再重现的问题引起的。虽然类似的问题可能是on-topi
我写了这段代码: MethodInfo method2 = typeof(IntPtr).GetMethod( "op_Explicit", Bind
我开始学习 Java,并且正在根据书本做一些练习。在执行此操作时,我遇到了以下错误:线程“main”java.util.InputMismatchException 中出现异常。我正在编写一个简单的程
我有一个文本文件,其中前两行是整数 m 和 n,然后有 m 行,每行都有 n 管道分隔值。我编写了一个程序,读取文件并使用文件中的值创建 m*n 数组,它工作了无数次,然后突然,使用相同的代码,使用相
所以我尝试使用在另一个类中生成的 bean 以在主应用程序中使用 package com.simon.spring.basics.properties; import org.spri
我还没有完成这个应用程序,但我希望在我的手机上看到它的样子。但是,它会强制关闭并引发 InstantiationException。 logcat 异常: 09-19 20:13:47.987: D/
我想从 UIViewController 加载一个基于 SwiftUI 的 View ,该 View 读取包本地的 json。仅 swiftUI 项目中的代码和绑定(bind)工作正常,当我利用 UI
'java.net.SocketTimeoutException:连接超时' 循环一段时间后我收到此错误。为什么我会收到 SocketTimeoutException?我该如何修复这个错误? @Ove
当有 null 值时抛出 ArgumentNullException() 是个好主意吗? This thread 没有提到在 null 上抛出的最明显的异常。 谢谢 最佳答案 ArgumentNull
我得到这个异常: NullReferenceException Object reference not set to an instance of an object at Namespace
所以其中一个方法的描述如下: public BasicLinkedList addToFront(T data) This operation is invalid for a sorted list
我正在使用 Intellij Idea,当我去生成 JavaDocs(通过工具 -> 生成 JavaDoc)时,我抛出了一个 IllegealArgumentException,没有关于发生了什么问题
我正在学习 C++ 中的互斥锁,但以下代码(摘自 N. Josuttis 的“C++ 标准库”)有问题。 我不明白为什么它会阻塞/抛出除非我在主线程中添加this_thread::sleep_for(
我正在试验 JavaFX 标签和组,通过鼠标拖动将它们移动到屏幕上。新节点从一些线程添加到动画组。但是,有时我会突然看到以下异常 - 我假设,当某些节点重叠时。但是不知道是什么问题……因为不涉及我的代
我是一名优秀的程序员,十分优秀!