Я работаю над 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
Получение повторяющихся строк в списке в Android ⇐ JAVA
Программисты JAVA общаются здесь
-
Anonymous
1736090405
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;
}
}
Подробнее здесь: [url]https://stackoverflow.com/questions/46047574/getting-duplicate-rows-in-listview-in-android[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия