Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- for (int a = 0; a<lv.getChildCount(); a++) {
- lv.getChildAt(a).setAlpha(0.5f);
- }
- Attempt to invoke virtual method 'void android.view.View.setAlpha(float)' on a null object reference
- public class SomeAdapter extends BaseAdapter {
- LayoutInflater layoutInflater;
- ArrayList<SomeClass> myList;
- private class ViewHolder{
- TextView tv1;
- ImageView iv1;
- }
- public SomeAdapter(Context mCon, ArrayList<SomeClass> list){
- this.myList = list;
- layoutInflater = LayoutInflater.from(mCon);
- this.context = mCon;
- }
- @Override
- public int getCount() {
- return myList.size();
- }
- @Override
- public ProfileEntry getItem(int position) {
- return myList.get(position);
- }
- @Override
- public long getItemId(int position) {
- return position;
- }
- @Override
- public View getView(int position, View convertView, ViewGroup parent) {
- ViewHolder holder = null;
- if (convertView == null){
- holder = new ViewHolder();
- convertView = layoutInflater.inflate(R.layout.row_profile,null);
- //находим элементы в разметке, но не меняем их
- holder.tv1 = (TextView)convertView.findViewById(R.id.tv_profileRow1);
- holder.iv1 = (ImageView) convertView.findViewById(R.id.iv_profileRow1);
- convertView.setTag(holder);
- }
- else {
- holder = (ViewHolder)convertView.getTag();
- }
- //тут назначаем свойства разметке в зависимости от данных
- if (myList.get(position).getSomeMethod().equals("Что-то")){
- // прописываем какой-то текст
- holder.tv1.setText("Укажите город");
- //устанавливаем картинку
- int picId = context.getResources().getIdentifier(myList.get(position).getImage(),"drawable",context.getPackageName());
- holder.iv1.setImageResource(picId);
- }else{
- holder.tv1.setText(myList.get(position).getAnotherMethod());
- int picId = context.getResources().getIdentifier(myList.get(position).getImage(),"drawable",context.getPackageName());
- holder.iv1.setImageResource(picId);
- }
Add Comment
Please, Sign In to add comment