Created
February 19, 2018 18:25
-
-
Save Avjeet/ebeb66fe4b9bfcf93adc2b477d1c0b27 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Holder extends RecyclerView.ViewHolder { | |
public TextView applicationName; | |
public ImageView applicationIcon; | |
public Holder(View itemView) { | |
super(itemView); | |
this.applicationName = (TextView) itemView.findViewById(R.id.application_name); | |
this.applicationIcon = (ImageView) itemView.findViewById(R.id.application_icon); | |
} | |
public void setup(final ApplicationItem applicationItem, final OnItemClickListener listener) { | |
applicationName.setText(applicationItem.getApplicationName()); | |
Picasso.with(mContext).load(applicationItem.getApplicationIcon()).into(applicationIcon); | |
itemView.setOnClickListener(new View.OnClickListener() { | |
@Override | |
public void onClick(View v) { | |
listener.onItemClick(applicationItem); | |
} | |
}); | |
} | |
} | |
public ApplicationAdapter(Context mContext, List<ApplicationItem> applicationList, OnItemClickListener listener) { | |
this.mContext = mContext; | |
this.applicationList = applicationList; | |
this.listener = listener; | |
if(mContext.getResources().getConfiguration().orientation | |
== Configuration.ORIENTATION_PORTRAIT){ | |
isPortraitMode=true; | |
} | |
} | |
@Override | |
public Holder onCreateViewHolder(ViewGroup parent, int viewType) { | |
View itemView = LayoutInflater.from(parent.getContext()) | |
.inflate(R.layout.application_list_item, parent, false); | |
if( isPortraitMode) { | |
height = ((View) parent.getParent()).getHeight(); | |
} | |
Log.e("item","itemView created"); | |
return new Holder(itemView); | |
} | |
@Override | |
public void onBindViewHolder(Holder holder, int position) { | |
if( isPortraitMode) { | |
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); | |
params.height=height/3; | |
holder.itemView.setLayoutParams(params); | |
Log.e("item"+position,"item"+position+"binded"); | |
} | |
holder.setup(applicationList.get(position), listener); | |
} | |
@Override | |
public int getItemCount() { | |
return applicationList.size(); | |
} | |
public interface OnItemClickListener { | |
void onItemClick(ApplicationItem item); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
but using this code I m getting only last two child views.
here is the logcat