0

通話ログを表示できるアプリケーションを作成しました。LazyAdapterクラスを使用しています。通話タイプに応じてアイコンを表示しています: Missed/ Incoming/ Outgoing. この部分が正常に動作していません。名前、番号、日付、時刻などのテキストの表示は、通話の種類を除いて問題なく表示されていますか?

これが私がやろうとしていることです:

  public class LazyAdapter extends BaseAdapter
  {

private Activity activity;
private ArrayList<HashMap<String, String>> data;
private static LayoutInflater inflater=null;

public LazyAdapter(Activity a, ArrayList<HashMap<String, String>> d)
{
    activity = a;
    data=d;

    inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}

public int getCount() 
{       
    return data.size();         
}

public Object getItem(int position) {
    return position;
}

public long getItemId(int position)
{

    return position;
}

public View getView(int position, View convertView, ViewGroup parent) 
{
    View vi=convertView;
    if(convertView==null)
        vi = inflater.inflate(R.layout.callist, null);


    TextView name = (TextView)vi.findViewById(R.id.name); 
    TextView number = (TextView)vi.findViewById(R.id.phone_number); 
    TextView date = (TextView)vi.findViewById(R.id.date); 
    TextView time = (TextView)vi.findViewById(R.id.time);
    TextView duration = (TextView)vi.findViewById(R.id.duration); 
    ImageView callType = (ImageView)vi.findViewById(R.id.calType);
    ImageView clock = (ImageView)vi.findViewById(R.id.Clock);


    HashMap<String, String> pro = new HashMap<String, String>();
    pro = data.get(position);


    if((pro.get(ListOfCall.contactName)!=null))
    {
        name.setText(pro.get(ListOfCall.contactName));      
    }
    else
    {
        name.setText("Unknown"); 
    }   
    number.setText(pro.get(ListOfCall.phone));
    date.setText(pro.get(ListOfCall.DateOfCall));
    time.setText(pro.get(ListOfCall.TimeOfCall));
    String  type = pro.get(ListOfCall.typeofCall);


    if(type.equalsIgnoreCase("OUTGOING"))
    {
        callType.setImageResource(R.drawable.outgoing); 
        duration.setText(pro.get(ListOfCall.durationOfCall));
    }
    else if(type.equalsIgnoreCase("INCOMING"))
    {
        callType.setImageResource(R.drawable.incoming); 
        duration.setText(pro.get(ListOfCall.durationOfCall));
    }
    else if(type.equalsIgnoreCase("MISSED"))
    {

        callType.setImageResource(R.drawable.missed);   
        duration.setVisibility(4);
        clock.setVisibility(4);
    }
    return vi;

}

}

arraylist上部の呼び出されたデータで正しい結果を得ることができるため、問題がどこにあるのかよくわかりません。arraylistをHashmapcalled proに移動すると、状況が変わります。

ここでも、呼び出しタイプを除いて値が適切に表示されており、それに対応する画像が表示されていません。

誰かがこれを修正するのを手伝ってくれますか?

4

1 に答える 1

0

LazyAdapter クラスにあった条件が必要に応じて機能しないことがわかりました。条件を削除し、値を LazyAdapter クラスに送信していたクラスの前に追加しました。

今は正常に動作します!!

ありがとう!

于 2013-06-19T10:29:51.493 に答える