Created
December 5, 2014 04:20
-
-
Save Krishan14sharma/efb651848c85de199262 to your computer and use it in GitHub Desktop.
RecyleViewAdapters
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
package com.dnn.zapbuild.commons.adapter; | |
import android.content.Context; | |
import android.view.LayoutInflater; | |
import android.view.View; | |
import android.view.ViewGroup; | |
import android.widget.ArrayAdapter; | |
import android.widget.TextView; | |
import com.dnn.zapbuild.commons.R; | |
import java.util.List; | |
/** | |
* A custom array adapter. | |
*/ | |
public class SingleLineAdapter extends ArrayAdapter<String> { | |
/** | |
* Current context | |
*/ | |
protected Context mContext; | |
private LayoutInflater mInflater; | |
// ------------------------------------------------------------- | |
// Constructors | |
// ------------------------------------------------------------- | |
public SingleLineAdapter(Context context, List<String> objects) { | |
super(context, 0, objects); | |
this.mContext = context; | |
mInflater = LayoutInflater.from(context); | |
} | |
// ------------------------------------------------------------- | |
// getView() | |
// ------------------------------------------------------------- | |
@Override | |
public View getView(int position, View convertView, ViewGroup parent) { | |
ViewHolder holder; | |
if (convertView == null) { | |
convertView = mInflater.inflate(R.layout.list_single_line, parent, false); | |
// Creates a ViewHolder and store references to the two children views | |
// we want to bind data to. | |
holder = new ViewHolder(); | |
// TODO store references to your views | |
holder.text = (TextView) convertView.findViewById(R.id.text); | |
convertView.setTag(holder); | |
} else { | |
// Get the ViewHolder back to get fast access to the TextView | |
// and the ImageView. | |
holder = (ViewHolder) convertView.getTag(); | |
} | |
String item = getItem(position); | |
if (item != null) { | |
// TODO Bind your data efficiently with the holder. | |
holder.text.setText(item); | |
} | |
return convertView; | |
} | |
// ------------------------------------------------------------- | |
// ViewHolder | |
// ------------------------------------------------------------- | |
private static class ViewHolder { | |
// TODO define members for each view in the item layout | |
public TextView text; | |
} | |
// ------------------------------------------------------------- | |
// Getters and Setters | |
// ------------------------------------------------------------- | |
public Context getContext() { | |
return mContext; | |
} | |
} |
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
package com.dnn.zapbuild.commons.adapter; | |
import android.content.Context; | |
import android.view.LayoutInflater; | |
import android.view.View; | |
import android.view.ViewGroup; | |
import android.widget.ArrayAdapter; | |
import android.widget.TextView; | |
import com.dnn.zapbuild.commons.R; | |
import java.util.List; | |
/** | |
* A custom array adapter. | |
*/ | |
public class SingleLineAvatarAdapter extends ArrayAdapter<String> { | |
/** | |
* Current context | |
*/ | |
protected Context mContext; | |
private LayoutInflater mInflater; | |
// ------------------------------------------------------------- | |
// Constructors | |
// ------------------------------------------------------------- | |
public SingleLineAvatarAdapter(Context context, List<String> objects) { | |
super(context, 0, objects); | |
this.mContext = context; | |
mInflater = LayoutInflater.from(context); | |
} | |
// ------------------------------------------------------------- | |
// getView() | |
// ------------------------------------------------------------- | |
@Override | |
public View getView(int position, View convertView, ViewGroup parent) { | |
ViewHolder holder; | |
if (convertView == null) { | |
convertView = mInflater.inflate(R.layout.list_avatar_single_item, parent, false); | |
// Creates a ViewHolder and store references to the two children views | |
// we want to bind data to. | |
holder = new ViewHolder(); | |
// TODO store references to your views | |
holder.text = (TextView) convertView.findViewById(R.id.text); | |
convertView.setTag(holder); | |
} else { | |
// Get the ViewHolder back to get fast access to the TextView | |
// and the ImageView. | |
holder = (ViewHolder) convertView.getTag(); | |
} | |
String item = getItem(position); | |
if (item != null) { | |
// TODO Bind your data efficiently with the holder. | |
holder.text.setText(item); | |
} | |
return convertView; | |
} | |
// ------------------------------------------------------------- | |
// ViewHolder | |
// ------------------------------------------------------------- | |
private static class ViewHolder { | |
// TODO define members for each view in the item layout | |
public TextView text; | |
} | |
// ------------------------------------------------------------- | |
// Getters and Setters | |
// ------------------------------------------------------------- | |
public Context getContext() { | |
return mContext; | |
} | |
} |
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
package com.dnn.zapbuild.commons.adapter; | |
import android.content.Context; | |
import android.view.LayoutInflater; | |
import android.view.View; | |
import android.view.ViewGroup; | |
import android.widget.ArrayAdapter; | |
import android.widget.TextView; | |
import com.dnn.zapbuild.commons.R; | |
import java.util.List; | |
/** | |
* A custom array adapter. | |
*/ | |
public class SingleLineAvatarIconAdapter extends ArrayAdapter<String> { | |
/** | |
* Current context | |
*/ | |
protected Context mContext; | |
private LayoutInflater mInflater; | |
// ------------------------------------------------------------- | |
// Constructors | |
// ------------------------------------------------------------- | |
public SingleLineAvatarIconAdapter(Context context, List<String> objects) { | |
super(context, 0, objects); | |
this.mContext = context; | |
mInflater = LayoutInflater.from(context); | |
} | |
// ------------------------------------------------------------- | |
// getView() | |
// ------------------------------------------------------------- | |
@Override | |
public View getView(int position, View convertView, ViewGroup parent) { | |
ViewHolder holder; | |
if (convertView == null) { | |
convertView = mInflater.inflate(R.layout.list_avatar_single_text_icon, parent, false); | |
// Creates a ViewHolder and store references to the two children views | |
// we want to bind data to. | |
holder = new ViewHolder(); | |
// TODO store references to your views | |
holder.text = (TextView) convertView.findViewById(R.id.text); | |
convertView.setTag(holder); | |
} else { | |
// Get the ViewHolder back to get fast access to the TextView | |
// and the ImageView. | |
holder = (ViewHolder) convertView.getTag(); | |
} | |
String item = getItem(position); | |
if (item != null) { | |
// TODO Bind your data efficiently with the holder. | |
holder.text.setText(item); | |
} | |
return convertView; | |
} | |
// ------------------------------------------------------------- | |
// ViewHolder | |
// ------------------------------------------------------------- | |
private static class ViewHolder { | |
// TODO define members for each view in the item layout | |
public TextView text; | |
} | |
// ------------------------------------------------------------- | |
// Getters and Setters | |
// ------------------------------------------------------------- | |
public Context getContext() { | |
return mContext; | |
} | |
} |
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
package com.dnn.zapbuild.commons.adapter; | |
import android.content.Context; | |
import android.view.LayoutInflater; | |
import android.view.View; | |
import android.view.ViewGroup; | |
import android.widget.ArrayAdapter; | |
import android.widget.TextView; | |
import com.dnn.zapbuild.commons.R; | |
import java.util.List; | |
/** | |
* A custom array adapter. | |
*/ | |
public class TwoLineAdapter extends ArrayAdapter<String> { | |
/** | |
* Current context | |
*/ | |
protected Context mContext; | |
private LayoutInflater mInflater; | |
// ------------------------------------------------------------- | |
// Constructors | |
// ------------------------------------------------------------- | |
public TwoLineAdapter(Context context, List<String> objects) { | |
super(context, 0, objects); | |
this.mContext = context; | |
mInflater = LayoutInflater.from(context); | |
} | |
// ------------------------------------------------------------- | |
// getView() | |
// ------------------------------------------------------------- | |
@Override | |
public View getView(int position, View convertView, ViewGroup parent) { | |
ViewHolder holder; | |
if (convertView == null) { | |
convertView = mInflater.inflate(R.layout.list_two_line, parent, false); | |
// Creates a ViewHolder and store references to the two children views | |
// we want to bind data to. | |
holder = new ViewHolder(); | |
// TODO store references to your views | |
holder.text = (TextView) convertView.findViewById(R.id.textview_primary); | |
convertView.setTag(holder); | |
} else { | |
// Get the ViewHolder back to get fast access to the TextView | |
// and the ImageView. | |
holder = (ViewHolder) convertView.getTag(); | |
} | |
String item = getItem(position); | |
if (item != null) { | |
// TODO Bind your data efficiently with the holder. | |
holder.text.setText(item); | |
} | |
return convertView; | |
} | |
// ------------------------------------------------------------- | |
// ViewHolder | |
// ------------------------------------------------------------- | |
private static class ViewHolder { | |
// TODO define members for each view in the item layout | |
public TextView text; | |
} | |
// ------------------------------------------------------------- | |
// Getters and Setters | |
// ------------------------------------------------------------- | |
public Context getContext() { | |
return mContext; | |
} | |
} |
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
package com.dnn.zapbuild.commons.adapter; | |
import android.content.Context; | |
import android.view.LayoutInflater; | |
import android.view.View; | |
import android.view.ViewGroup; | |
import android.widget.ArrayAdapter; | |
import android.widget.TextView; | |
import com.dnn.zapbuild.commons.R; | |
import java.util.List; | |
/** | |
* A custom array adapter. | |
*/ | |
public class TwoLineAvatarAdapter extends ArrayAdapter<String> { | |
/** | |
* Current context | |
*/ | |
protected Context mContext; | |
private LayoutInflater mInflater; | |
// ------------------------------------------------------------- | |
// Constructors | |
// ------------------------------------------------------------- | |
public TwoLineAvatarAdapter(Context context, List<String> objects) { | |
super(context, 0, objects); | |
this.mContext = context; | |
mInflater = LayoutInflater.from(context); | |
} | |
// ------------------------------------------------------------- | |
// getView() | |
// ------------------------------------------------------------- | |
@Override | |
public View getView(int position, View convertView, ViewGroup parent) { | |
ViewHolder holder; | |
if (convertView == null) { | |
convertView = mInflater.inflate(R.layout.list_avatar_two_line, parent, false); | |
// Creates a ViewHolder and store references to the two children views | |
// we want to bind data to. | |
holder = new ViewHolder(); | |
// TODO store references to your views | |
holder.text = (TextView) convertView.findViewById(R.id.textview_primary); | |
convertView.setTag(holder); | |
} else { | |
// Get the ViewHolder back to get fast access to the TextView | |
// and the ImageView. | |
holder = (ViewHolder) convertView.getTag(); | |
} | |
String item = getItem(position); | |
if (item != null) { | |
// TODO Bind your data efficiently with the holder. | |
holder.text.setText(item); | |
} | |
return convertView; | |
} | |
// ------------------------------------------------------------- | |
// ViewHolder | |
// ------------------------------------------------------------- | |
private static class ViewHolder { | |
// TODO define members for each view in the item layout | |
public TextView text; | |
} | |
// ------------------------------------------------------------- | |
// Getters and Setters | |
// ------------------------------------------------------------- | |
public Context getContext() { | |
return mContext; | |
} | |
} |
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
package com.dnn.zapbuild.commons.adapter; | |
import android.content.Context; | |
import android.view.LayoutInflater; | |
import android.view.View; | |
import android.view.ViewGroup; | |
import android.widget.ArrayAdapter; | |
import android.widget.TextView; | |
import com.dnn.zapbuild.commons.R; | |
import java.util.List; | |
/** | |
* A custom array adapter. | |
*/ | |
public class TwoLineIconAdapter extends ArrayAdapter<String> { | |
/** | |
* Current context | |
*/ | |
protected Context mContext; | |
private LayoutInflater mInflater; | |
// ------------------------------------------------------------- | |
// Constructors | |
// ------------------------------------------------------------- | |
public TwoLineIconAdapter(Context context, List<String> objects) { | |
super(context, 0, objects); | |
this.mContext = context; | |
mInflater = LayoutInflater.from(context); | |
} | |
// ------------------------------------------------------------- | |
// getView() | |
// ------------------------------------------------------------- | |
@Override | |
public View getView(int position, View convertView, ViewGroup parent) { | |
ViewHolder holder; | |
if (convertView == null) { | |
convertView = mInflater.inflate(R.layout.list_icon_two_line, parent, false); | |
// Creates a ViewHolder and store references to the two children views | |
// we want to bind data to. | |
holder = new ViewHolder(); | |
// TODO store references to your views | |
holder.text = (TextView) convertView.findViewById(R.id.textview_primary); | |
convertView.setTag(holder); | |
} else { | |
// Get the ViewHolder back to get fast access to the TextView | |
// and the ImageView. | |
holder = (ViewHolder) convertView.getTag(); | |
} | |
String item = getItem(position); | |
if (item != null) { | |
// TODO Bind your data efficiently with the holder. | |
holder.text.setText(item); | |
} | |
return convertView; | |
} | |
// ------------------------------------------------------------- | |
// ViewHolder | |
// ------------------------------------------------------------- | |
private static class ViewHolder { | |
// TODO define members for each view in the item layout | |
public TextView text; | |
} | |
// ------------------------------------------------------------- | |
// Getters and Setters | |
// ------------------------------------------------------------- | |
public Context getContext() { | |
return mContext; | |
} | |
} |
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
package com.dnn.zapbuild.commons.adapter; | |
import android.support.v4.app.Fragment; | |
import android.support.v4.app.FragmentManager; | |
import android.support.v4.app.FragmentPagerAdapter; | |
import com.dnn.zapbuild.commons.fragment.SampleFragment; | |
public class ViewPagerAdapter extends FragmentPagerAdapter { | |
final int PAGE_COUNT =8; | |
private String titles[] ; | |
public ViewPagerAdapter(FragmentManager fm, String[] titles2) { | |
super(fm); | |
titles=titles2; | |
} | |
@Override | |
public Fragment getItem(int position) { | |
switch (position) { | |
// Open FragmentTab1.java | |
case 0: | |
return SampleFragment.newInstance(position); | |
case 1: | |
return SampleFragment.newInstance(position); | |
case 2: | |
return SampleFragment.newInstance(position); | |
case 3: | |
return SampleFragment.newInstance(position); | |
case 4: | |
return SampleFragment.newInstance(position); | |
case 5: | |
return SampleFragment.newInstance(position); | |
case 6: | |
return SampleFragment.newInstance(position); | |
case 7: | |
return SampleFragment.newInstance(position); | |
} | |
return null; | |
} | |
public CharSequence getPageTitle(int position) { | |
return titles[position]; | |
} | |
@Override | |
public int getCount() { | |
return PAGE_COUNT; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment