2016-10-27 23 views
-1

WebからJSONデータを取得するときに、パッケージ名が文字列名の代わりに表示されます。私は、エラーがgetItem、getpositionなどのメソッドにあると思います。package com.bibek.json; ログを表示すると、表示されるエラーは 10-27 15:59:29.914 7611-7611/com.bibek.json V/hari:[email protected] 10-27 15: 59:29.964 7611-7611/com.bibek.json V/hari:[email protected] 10-27 15:59:30.034 7611-7611/com.bibek.json V/hari:hehecom .bibek.json.data.SongModel @何Object#toString()戻ります文字列名の代わりにパッケージ名が表示されます

import android.content.Context; 
import android.util.Log; 
import android.view.LayoutInflater; 
import android.view.View; 
import android.view.ViewGroup; 
import android.widget.ArrayAdapter; 
import android.widget.TextView; 

import com.bibek.json.data.SongModel; 

import java.util.ArrayList; 
import java.util.List; 

/** 
* Created by User on 10/27/2016. 
    package com.example.shailendra.navigaiontab; 

    import android.content.Context; 
    import android.view.LayoutInflater; 
    import android.view.View; 
    import android.view.ViewGroup; 
    import android.widget.ArrayAdapter; 
    import android.widget.ImageView; 
    import android.widget.TextView; 

    /** 
    * Created by Shailendra on 10/19/2016. 
    */ 
    public class CustomAdapter extends ArrayAdapter{ 
     TextView textView5; 
    private List data; 

     public CustomAdapter(Context context, List<SongModel> s) { 
      super(context, R.layout.row,s); 
      data=s; 
     } 


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

    @Override 
    public Object getItem(int position) { 
     return super.getItem(position); 
    } 

    @Override 
    public long getItemId(int position) { 
     return position; 
    } 

    @Override 
    public int getPosition(Object item) { 
     return getPosition(item); 
    } 

    @Override 
     public View getView(int position, View convertView, ViewGroup parent) { 
      LayoutInflater newInflator= LayoutInflater.from(getContext()); 
      View customView= newInflator.inflate(R.layout.row,parent,false); 
      String myitem= getItem(position).toString(); 
      textView5=(TextView)customView.findViewById(R.id.songId); 
      // ImageView imageView=(ImageView)convertView.findViewById(R.id.imageView2); 


      textView5.setText(myitem); 
      Log.v("hari ", "hehe" + myitem); 

      return customView; 
     } 
    } 
+0

SongModelのどの情報を表示したいですか? – Blackbelt

答えて

2

f1e15d3。

toString()の結果として他のものを表示する場合は、SongModelクラスのメソッドをオーバーライドして、必要な文字列表現を返します。

関連する問題