Получение повторяющихся строк в списке в AndroidJAVA

Программисты JAVA общаются здесь
Ответить
Anonymous
 Получение повторяющихся строк в списке в Android

Сообщение Anonymous »

Я работаю над listView, который заполняет данные из веб-службы, я получаю полные необходимые результаты от веб-службы в json, но когда я устанавливаю его в адаптере в listview, я получаю только повторяющиеся строки, у меня также есть проверил мой массив, он идеален.
public class ListingAdapter extends BaseAdapter {
private Activity mContext;
ArrayList busList;

public ListingAdapter(Activity c, ArrayList busList) {
mContext = c;
this.busList = busList;
}

@Override
public int getCount() {
// TODO Auto-generated method stub
return busList.size();
}

@Override
public Object getItem(int position) {
// TODO Auto-generated method stub
return null;
}

@Override
public long getItemId(int position) {
// TODO Auto-generated method stub
return 0;
}

@Override
public View getView(final int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
View grid;
LayoutInflater inflater = (LayoutInflater) mContext.getLayoutInflater();

if (convertView == null) {

grid = new View( mContext );
grid = inflater.inflate( R.layout.raw_tab, null );
TextView tv_cat = (TextView) grid.findViewById( R.id.tv_cat );
ImageView iv_pic = (ImageView) grid.findViewById( R.id.iv_pic );
TextView tv_features = (TextView) grid.findViewById( R.id.tv_features );
TextView tv_location = (TextView) grid.findViewById( R.id.tv_location );
TextView tv_rating = (TextView) grid.findViewById( R.id.tv_rating );
RatingBar rt_bar = (RatingBar) grid.findViewById( R.id.rt_fvrt );
TextView tv_votes = (TextView) grid.findViewById( R.id.tv_votes );
ImageView iv_call = (ImageView) grid.findViewById( R.id.iv_call );
ImageView iv_share = (ImageView) grid.findViewById( R.id.iv_share );

tv_cat.setText( busList.get( position ).getBiz_name() );
tv_features.setText( busList.get( position ).getFeatures() );
tv_location.setText( busList.get( position ).getCity() );
tv_rating.setText( busList.get( position ).getAverage_rate() );
tv_votes.setText( busList.get( position ).getVotes() );
rt_bar.setRating( Float.parseFloat( busList.get( position ).getAverage_rate() ) );
if(!busList.get( position ).getImg_1().equals( "" )){
Picasso.with( mContext )
.load( busList.get( position ).getImg_1().replaceAll(" ", "%20") )
.placeholder( R.drawable.ic_no_img )
.error( R.drawable.ic_no_img )
.into( iv_pic );
}

iv_call.setOnClickListener( new View.OnClickListener() {
@Override
public void onClick(View v) {

Intent intent = new Intent( Intent.ACTION_CALL );

intent.setData( Uri.parse( "tel:" + (busList.get( position ).getMobile_1()) ) );
if (ActivityCompat.checkSelfPermission( mContext, Manifest.permission.CALL_PHONE ) != PackageManager.PERMISSION_GRANTED) {
// TODO: Consider calling
// ActivityCompat#requestPermissions
// here to request the missing permissions, and then overriding
// public void onRequestPermissionsResult(int requestCode, String[] permissions,
// int[] grantResults)
// to handle the case where the user grants the permission. See the documentation
// for ActivityCompat#requestPermissions for more details.
return;
}
mContext.startActivity( intent );
}
} );

iv_share.setOnClickListener( new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent sharingIntent = new Intent( Intent.ACTION_SEND );
sharingIntent.setType( "text/html" );
sharingIntent.putExtra( android.content.Intent.EXTRA_TEXT, Html.fromHtml( "TEst From all About City." ) );
mContext.startActivity( Intent.createChooser( sharingIntent, "Share using" ) );
}
} );
} else {
grid = (View) convertView;
}

return grid;
}
}


Подробнее здесь: https://stackoverflow.com/questions/460 ... in-android
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «JAVA»