我正在开发一个Android应用程序,我必须在数据库中显示自定义警报对话框的数据。这是我的数据库
我试图通过以下代码
在警告对话框a上显示所有这些数据 public View getView(int position, View convertView, ViewGroup parent) {
Log.d(TAG, "Position " + position);
int _id = 0;
int type = getItemViewType(position);
OrderViewHolder orderViewHolder = null;
if (convertView == null) {
orderViewHolder = new OrderViewHolder();
switch (type) {
case TYPE_STATUS:
convertView = inflater.inflate(R.layout.category_header, null);
orderViewHolder.setTvTitle((TextView) convertView
.findViewById(R.id.category));
break;
case TYPE_ITEM:
convertView = inflater.inflate(R.layout.order_list_row, null);
orderViewHolder.setTvTitle((TextView) convertView
.findViewById(R.id.orderTitle));
orderViewHolder.setTvPrice((TextView) convertView
.findViewById(R.id.orderPrice));
orderViewHolder.setIvDelete((ImageButton) convertView
.findViewById(R.id.deleteOrder));
// orderViewHolder.setIvDelete((ImageButton)convertView.findViewById(R.id.deleteOrder).setLayoutParams(params))
break;
}
convertView.setTag(orderViewHolder);
} else {
orderViewHolder = (OrderViewHolder) convertView.getTag();
}
if (position == 0) {
if (starterCount != 0) {
orderViewHolder.getTvTitle().setText("");
// orderViewHolder.getTvTitle().setBackgroundDrawable(R.drawable.tab_starters_menu_on);
orderViewHolder.getTvTitle().setTextColor(R.color.Black);
orderViewHolder.getTvTitle().setTextSize(12);
orderViewHolder.getTvTitle().setTypeface(Typeface.DEFAULT_BOLD);
orderViewHolder.getTvTitle().setBackgroundResource(R.drawable.tt111);
orderViewHolder.getTvTitle().setHeight(20);
orderViewHolder.getTvTitle().setWidth(100);
/*
* RestaurantHome.setFontTextViewTahoma(OrderListAdapter,
* orderViewHolder.getTvTitle());
*/
}
else {
orderViewHolder.getTvTitle().setText(" ");
orderViewHolder.getTvTitle().setBackgroundColor(Color.WHITE);
}
}
if ((position !=0))
{
System.out.println(" position vlue : "+position);
if (oStarterCursor.moveToPosition(position-1)) {
String title = oStarterCursor.getString(oStarterCursor.getColumnIndex("item_name"));
System.out.println( " value of title "+title);
String price = oStarterCursor.getString(oStarterCursor.getColumnIndex("Item_cost"));
System.out.println( " value of price "+price);
_id = oStarterCursor.getInt(oStarterCursor
.getColumnIndex("_id"));
if (title != null) {
title = title.trim();
orderViewHolder.getTvTitle().setText(title);
orderViewHolder.getTvTitle().setTextColor(R.color.black);
orderViewHolder.getTvTitle().setTextSize(12);
orderViewHolder.getTvTitle().setTypeface(Typeface.DEFAULT);
orderViewHolder.getTvTitle().setGravity(Gravity.CENTER_VERTICAL);
}
if (price != null) {
price = price.trim();
orderViewHolder.getTvPrice().setText(price + ".00");
orderViewHolder.getTvTitle().setTextColor(R.color.black);
orderViewHolder.getTvTitle().setTextSize(12);
orderViewHolder.getTvTitle().setTypeface(Typeface.DEFAULT);
orderViewHolder.getTvTitle().setGravity(Gravity.CENTER_VERTICAL);
}
_id = oStarterCursor.getInt(oStarterCursor.getColumnIndex("_id"));
}
convertView.setTag(R.id.orderTitle, _id);
if (orderViewHolder.getIvDelete() != null) {
orderViewHolder.getIvDelete().setTag(R.id.orderTitle, _id);
}
// _id =
// oStarterCursor.getInt(oStarterCursor.getColumnIndex("_id"));
}
//}
return convertView;}
但它没有在我的数据库中显示我的最后一个数据。
正如您在屏幕截图中看到的,最后一个数据未显示表单数据库。为什么芬达不露面?始终最后一行显示在来自数据库的alertdialog中。我的代码中的逻辑问题是我无法理解的。我希望我能够向所有善良的人解释我的问题。请帮我 。在此先感谢所有