- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我的列表有这样的 Activity :
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<ListView
android:id="@+id/altOrderslist"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:divider="#b5b5b5"
android:dividerHeight="1dp"
/>
</RelativeLayout>
我想用这些项目制作自定义 ListView :
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="5dip" >
<!-- ListRow Left sied Thumbnail image -->
<LinearLayout
android:id="@+id/thumbnail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginRight="5dip"
android:padding="3dip" >
<TextView
android:id="@+id/altOrderId"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Rihanna Love the way lie"
android:textColor="#040404"
android:textSize="15dip"
android:textStyle="bold"
android:typeface="sans" />
</LinearLayout>
<!-- Title Of Song -->
<!-- Artist Name -->
<TextView
android:id="@+id/altOrderTitle"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="1dip"
android:layout_toRightOf="@+id/thumbnail"
android:text="Just gona stand there and ..."
android:textColor="#343434"
android:textSize="10dip" />
<!-- Rightend Duration -->
<TextView
android:id="@+id/altOrderStatus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginRight="5dip"
android:gravity="right"
android:textColor="#10bcc9"
android:textSize="10dip"
android:textStyle="bold" />
<!-- Rightend Arrow -->
<TextView
android:id="@+id/altOrderPrice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignTop="@+id/thumbnail"
android:text="Rihanna Love the way lie"
android:textColor="#040404"
android:textSize="15dip"
android:textStyle="bold"
android:typeface="sans" />
</RelativeLayout>
这是我的适配器类:
public class OrderAdapter extends ArrayAdapter<Order>{
Context context;
int layoutResourceId;
List<Order> orders = null;
public OrderAdapter(Context context, int layoutResourceId, List<Order> orders) {
super(context, layoutResourceId, orders);
this.layoutResourceId = layoutResourceId;
this.context = context;
this.orders = orders;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View row = convertView;
OrderHolder holder = null;
if(row == null)
{
Log.i("I'm in OrderAdapter",Integer.toString(layoutResourceId));
LayoutInflater inflater = ((Activity)context).getLayoutInflater();
row = inflater.inflate(R.layout.dash_alt_item, parent, false);
Log.i("I'm in OrderAdapter",Integer.toString(layoutResourceId));
holder = new OrderHolder();
holder.orderId = (TextView)row.findViewById(R.id.altOrderId);
holder.orderTitle = (TextView)row.findViewById(R.id.altOrderTitle);
holder.orderStatus = (TextView)row.findViewById(R.id.altOrderStatus);
holder.orderPrice = (TextView)row.findViewById(R.id.altOrderPrice);
//row.setTag(holder);
}
else
{
holder = (OrderHolder)row.getTag();
}
Order order = orders.get(position);
holder.orderId.setText(order.getOrderid());
holder.orderTitle.setText(order.getTitle());
holder.orderStatus.setText(order.getProcess_status().getProccessStatusTitle());
holder.orderPrice.setText(Float.toString(order.getPrice()));
return row;
}
static class OrderHolder
{
TextView orderId;
TextView orderTitle;
TextView orderStatus;
TextView orderPrice;
}
}
以及我如何在 Activity 中使用它:
public class DashboardActivityAlt extends Activity{
static List<Order> orders;
List<Order> forPrint = new ArrayList<Order>();
private ListView listView1;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.dash_alt);
try {
this.getOrderList("1", "10"); **// filling the forPrint list**
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
OrderAdapter adapter = new OrderAdapter(this,
R.layout.dash_alt_item, **forPrint**);
listView1 = (ListView)findViewById(R.id.altOrderslist);
listView1.setAdapter(adapter);
}
我在 holder.orderId.setText(order.getOrderid());
这行得到了 ResourceNotFoundException这是什么原因?
最佳答案
确保您没有将 int 传递给该方法。将其转换为字符串并将按预期开始工作。
原因是 setText() 重载了它有多个版本:
setText(int resId)
setText(String text)
关于android - 自定义 ListView 适配器的 ResourceNotFoundException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12408918/
我正在使用 Spring Boot 并尝试创建一个测试。 实际上我的测试类: @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment=W
很难说出这里问的是什么。这个问题是含糊的、模糊的、不完整的、过于宽泛的或修辞性的,无法以目前的形式得到合理的回答。如需帮助澄清此问题以便重新打开它,visit the help center 。 已关
我有以下类(class): public class EmailService { static { Velocity.setProperty("resource.loader
我会自定义抽屉导航。我在另一个线程中使用了在 stackoverflow 上找到的示例。代码是复制粘贴,但是在logcat中运行应用程序时出现异常:“ResourceNotFoundException
我在 Market 上收到了一些关于此异常的报告。没有提到它在我的应用程序中发生的位置,大多数用户没有这个问题。我该如何调试这样的东西?这不是我从所有设备上得到的异常(exception)。只有一个特
我想知道是否有人可以帮助我。我在我的 android 应用程序中收到 ResourceNotFoundException。运行以下代码时发生(异常发生在getString()调用) c
当我尝试在我的 Samsung Note II 上运行我的应用程序时,我收到此行的 ResourceNotFoundException setContentView(R.layout.activity
我有一个Recyclerview。在它的适配器中,这就是我所拥有的: @Override public void onBindViewHolder(@NonNull ViewHolder holde
概要 我通过aws lambda使AWS SAM函数。 此功能需要数据库,因此我选择DynamoDB。 现在,我为AWS SAM和DynamoDB设置本地环境。 看来我成功设置了本地DynamoDB,
我正在尝试基于 scalatra-sbt.g8 的以下内容: class FooWeb extends ScalatraServlet with ScalateSupport { beforeAl
我为 ListView 项创建了一个构造函数DataPembeli,然后创建了自定义 ListView 适配器DataPembeliListAdapter并使用这样的构造函数: txtid.setTe
我这样创建自己的样式属性: 我在我的主题中赋予它这样的值(value): @color/blue 如果我在我的布局中访问它(已设置为 contentView) 它就像一个魅力。但是如果我
当我的 android 应用程序以纵向屏幕启动时,操作栏中有选项菜单;但是当切换到 landspace 时,我发现资源未找到异常。 inflater.inflate(R.menu.main, menu
我已经拥有的: 这是我的 ImageView: 我使用的是 Android 插件版本 2.0: classpath 'com.android.tools.build:gradle:2.0.0' 我在
我最近检查了我的 GP 崩溃日志,我经常收到这个调用堆栈。请你帮助我好吗。 一些事情: 添加资源路径失败有时显示/data/app/com.xxx.xxx.xxx-x/base.apk,有时显示/mn
07-25 10:15:37.960: E/AndroidRuntime(8661): android.content.res.Resources$NotFoundException: String
在基本的 Skobbler 应用程序中,当调用 InitializeSKMaps 时,会抛出 ResourceNotFoundException 并引用“字符串资源 ID #0x0”。为什么会这样?
我有一个自定义 View ,我们将其称为CustomView。在初始化时,我调用了以下方法 textPaint.setTypeface(ResourcesCompat.getFont(getConte
我正在尝试将原始文件夹中的音乐文件设置为在打开 NewActivity 的 ListView 中播放。我已经配置了 Model 类、MainActivity 和 ListviewAdapter,但仍然
我正在开发一个 Android 应用程序,并在其中生成一些 PDF 文件。一旦生成,我就启动一个应用程序的Intent来显示PDF(如Acrobat)。 一旦我按返回键返回到我的应用程序,它就会在采用
我是一名优秀的程序员,十分优秀!