0

4 つのテキストフィールドにデータを入力する arrayadapter があります。テキストフィールドに値を入力しようとするときの getView メソッド。エラー android.content.res.Resources$NotFoundException: String resource ID #0x11 が表示されます。修正が必要なところまでご案内いただけますでしょうか。

以下はArrayAdapterコードです

public class AdapterTicketList extends ArrayAdapter<POJO_Ticket> {
Context context;
ArrayList<POJO_Ticket> ticketArray;
LayoutInflater vi;

public AdapterTicketList(Context context , ArrayList<POJO_Ticket> ticketArray) {    
    super(context, 0, ticketArray );    
    this.ticketArray = new ArrayList<POJO_Ticket>();    
    this.ticketArray.addAll(ticketArray);  
    this.context =context;

    vi = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);  
    }  

private class ViewHolder {
    TextView tvTicketID;  
    TextView tvCreationHour;  
    TextView tvTableNumber;     
    TextView tvAmount;    
    } 

public View getView(final int position, View convertView, ViewGroup parent) {      
    ViewHolder holder;    
    holder = new ViewHolder();
    if (convertView == null) {                   
        convertView = vi.inflate(R.layout.rowticket,  null);  
        holder.tvTicketID = (TextView) convertView.findViewById(R.id.tvTicketID); 
        holder.tvCreationHour = (TextView) convertView.findViewById(R.id.tvCreationHour); 
        holder.tvTableNumber = (TextView) convertView.findViewById(R.id.tvTableNumber); 
        holder.tvAmount = (TextView) convertView.findViewById(R.id.tvQuantity);  
        convertView.setTag(holder); 
    } else {
        holder = (ViewHolder) convertView.getTag();  
    }       
    Ticket ticket =ticketArray.get(position).getTicketObject();

    Log.i("AdapterTicketList"," ticket id : " + ticket.getId()); 
    holder.tvTicketID.setText(String.valueOf(ticket.getId())) ;  
    holder.tvCreationHour.setText(String.valueOf(ticket.getCreationHour())) ;  
    holder.tvTableNumber.setText(String.valueOf(ticket.getTableNumber())) ;   
    holder.tvAmount.setText( String.valueOf((ticket.getTotalAmount())))  ; 
    return convertView; 
    } 

}

01-09 00:11:15.337: E/AndroidRuntime(10204): FATAL EXCEPTION: main
01-09 00:11:15.337: E/AndroidRuntime(10204): java.lang.NullPointerException
01-09 00:11:15.337: E/AndroidRuntime(10204): at com.example.restaurent.AdapterTicketList.getView(AdapterTicketList.java:59)
01-09 00:11:15.337: E/AndroidRuntime(10204): at android.widget.AbsListView.obtainView(AbsListView.java:2040)
01-09 00:11:15.337: E/AndroidRuntime(10204): at android.widget.ListView.makeAndAddView(ListView.java:1772)
01-09 00:11:15.337: E/AndroidRuntime(10204): at android.widget.ListView.fillDown(ListView.java:672)
01-09 00:11:15.337: E/AndroidRuntime(10204): at android.widget.ListView.fillFromTop(ListView.java:732)
01-09 00:11:15.337: E/AndroidRuntime(10204): at android.widget.ListView.layoutChildren(ListView.java:1625)
01-09 00:11:15.337: E/AndroidRuntime(10204): at android.widget.AbsListView.onLayout(AbsListView.java:1870)
01-09 00:11:15.337: E/AndroidRuntime(10204): at android.view.View.layout(View.java:11418)
01-09 00:11:15.337: E/AndroidRuntime(10204): at android.view.ViewGroup.layout(ViewGroup.java:4328)
01-09 00:11:15.337: E/AndroidRuntime(10204): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1652)
01-09 00:11:15.337: E/AndroidRuntime(10204): at android.widget.LinearLayout.layoutHorizontal(LinearLayout.java:1641)
01-09 00:11:15.337: E/AndroidRuntime(10204): at android.widget.LinearLayout.onLayout(LinearLayout.java:1417)
01-09 00:11:15.337: E/AndroidRuntime(10204): at android.view.View.layout(View.java:11418)
01-09 00:11:15.337: E/AndroidRuntime(10204): at android.view.ViewGroup.layout(ViewGroup.java:4328)
01-09 00:11:15.337: E/AndroidRuntime(10204): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1652)
01-09 00:11:15.337: E/AndroidRuntime(10204): at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1510)
01-09 00:11:15.337: E/AndroidRuntime(10204): at android.widget.LinearLayout.onLayout(LinearLayout.java:1415)
01-09 00:11:15.337: E/AndroidRuntime(10204): at android.view.View.layout(View.java:11418)
01-09 00:11:15.337: E/AndroidRuntime(10204): at android.view.ViewGroup.layout(ViewGroup.java:4328)
01-09 00:11:15.337: E/AndroidRuntime(10204): at android.widget.FrameLayout.onLayout(FrameLayout.java:443)
01-09 00:11:15.337: E/AndroidRuntime(10204): at android.view.View.layout(View.java:11418)
01-09 00:11:15.337: E/AndroidRuntime(10204): at android.view.ViewGroup.layout(ViewGroup.java:4328)
01-09 00:11:15.337: E/AndroidRuntime(10204): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1652)
01-09 00:11:15.337: E/AndroidRuntime(10204): at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1510)
01-09 00:11:15.337: E/AndroidRuntime(10204): at android.widget.LinearLayout.onLayout(LinearLayout.java:1415)
01-09 00:11:15.337: E/AndroidRuntime(10204): at android.view.View.layout(View.java:11418)
01-09 00:11:15.337: E/AndroidRuntime(10204): at android.view.ViewGroup.layout(ViewGroup.java:4328)
01-09 00:11:15.337: E/AndroidRuntime(10204): at android.widget.FrameLayout.onLayout(FrameLayout.java:443)
01-09 00:11:15.337: E/AndroidRuntime(10204): at android.view.View.layout(View.java:11418)
01-09 00:11:15.337: E/AndroidRuntime(10204): at android.view.ViewGroup.layout(ViewGroup.java:4328)
01-09 00:11:15.337: E/AndroidRuntime(10204): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1489)
01-09 00:11:15.337: E/AndroidRuntime(10204): at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2442)
01-09 00:11:15.337: E/AndroidRuntime(10204): at android.os.Handler.dispatchMessage(Handler.java:99)
01-09 00:11:15.337: E/AndroidRuntime(10204): at android.os.Looper.loop(Looper.java:137)
01-09 00:11:15.337: E/AndroidRuntime(10204): at android.app.ActivityThread.main(ActivityThread.java:4441)
01-09 00:11:15.337: E/AndroidRuntime(10204): at java.lang.reflect.Method.invokeNative(Native Method)
01-09 00:11:15.337: E/AndroidRuntime(10204): at java.lang.reflect.Method.invoke(Method.java:511)
01-09 00:11:15.337: E/AndroidRuntime(10204): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
01-09 00:11:15.337: E/AndroidRuntime(10204): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
01-09 00:11:15.337: E/AndroidRuntime(10204): at dalvik.system.NativeStart.main(Native Method)
4

1 に答える 1

0

数値を文字列に変換するため、この行は正しいです。

holder.tvAmount.setText(Double.toString(ticketArray.get(position).getTicketObject().getTotalAmount())) ; 

これらは数値を取得するように見えるため、潜在的な問題があります。

holder.tvTicketID.setText(ticketArray.get(position).getTicketObject().getId()) ;  
holder.tvCreationHour.setText(ticketArray.get(position).getTicketObject().getCreationHour()) ;  
holder.tvTableNumber.setText(ticketArray.get(position).getTicketObject().getTableNumber()) ;   

解決策:文字列または適切な整数を に渡す必要があります。R.string.xxxsetText()

だから使用:

holder.tvTicketID.setText(String.valueOf(ticketArray.get(position).getTicketObject().getId()));
// etc  

ticketArray.get(position).getTicketObject()(繰り返しフェッチするのではなく、ローカル変数に保存することも検討する必要があります。)

于 2013-01-08T18:08:06.613 に答える