how to inser ViewPager in to Custom RecyclerView android?
please help me .
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType)
{
View view =
LayoutInflater.from(parent.getContext()).inflate(R.layout.mnlist ,
parent, false);
viewPager = (ViewPager) view.findViewById(R.id.viewpager);
setupViewPager(viewPager);
return new ListViewHolder(view);
}
What to write getSupportFragmentManager() ?
private void setupViewPager(ViewPager viewPager)
{
ViewPagerAdapter adapter = new
ViewPagerAdapter(getSupportFragmentManager());
adapter.addFragment(new HomeFragment(),"a");
adapter.addFragment(new OneFragment(), "b");
adapter.addFragment(new TwoFragment(),"c");
viewPager.setAdapter(adapter);
}
i write code following ,but not answer , Because "ForceClose Activity".
#Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
((ListViewHolder) holder).bindView(position);
ViewPagerAdapter adapter = new ViewPagerAdapter(((AppCompatActivity) ctx).getSupportFragmentManager());
viewPager.setAdapter(adapter);
tabLayout.setupWithViewPager(viewPager);
viewPager.setOffscreenPageLimit(2);
}
public class ViewPagerAdapter extends FragmentStatePagerAdapter {
private String[] tabTitles = new String[] {"Tab 1", "Tab 2"};
public ViewPagerAdapter(FragmentManager fm) {
super(fm);
}
#Override
public Fragment getItem(int position) {
switch (position) {
case 0:
Tab1 tab1 = new Tab1();
return tab1 ;
case 1:
Tab2 tab2 = new Tab2();
return tab2 ;
default:
return null;
}
}
#Override
public int getCount() {
return tabTitles.length;
}
#Override
public CharSequence getPageTitle(int position) {
return tabTitles[position];
}
}
Related
Item list instantiates but the items but click event (toast) doesnt occur when clicked.
public class MainActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener {
private DrawerLayout drawerLayout;
private NavigationView navigationView;
Toolbar toolbar;
FragmentTransaction fragmentTransaction;
FragmentManager fragmentManager;
Fragment fragment;
FrameLayout frameLayout;
ListView listView;
String[] workoutsRoutines = {"Upper Body", "Lower body"};
int[] workoutsBackgrounds = {R.drawable.ic_launcher_background, R.drawable.ic_launcher_foreground};
int count;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
drawerLayout = findViewById(R.id.drawer_layout);
navigationView = findViewById(R.id.nav_view);
navigationView.bringToFront();
navigationView.setNavigationItemSelectedListener(this);
toolbar = findViewById(R.id.toolbar);
toolbar.setTitle(null);
toolbar.setNavigationIcon(R.drawable.ic_android_black_24dp);
item list click event
listView = findViewById(R.id.listview);
CustomAdapter customAdapter = new CustomAdapter();
listView.setAdapter(customAdapter);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> parent, View view, int i, long id) {
Toast.makeText(MainActivity.this, "succ", Toast.LENGTH_SHORT).show();
}
});
toolbar.setNavigationOnClickListener(v -> {
drawerLayout.openDrawer(GravityCompat.START);
Toast.makeText(MainActivity.this, "succ", Toast.LENGTH_SHORT).show();
if (drawerLayout.isDrawerOpen(GravityCompat.START)) {
drawerLayout.closeDrawer(GravityCompat.START);
}
if (fragment != null) {
count = fragmentManager.getBackStackEntryCount();
for (int i = 0; i < count; i++) {
fragmentManager.popBackStack();
drawerLayout.closeDrawer(GravityCompat.START);
}
fragmentManager = getSupportFragmentManager();
fragmentTransaction = fragmentManager.beginTransaction().remove(fragment);
fragmentTransaction.commit();
}
toolbar.setNavigationIcon(R.drawable.ic_android_black_24dp);
});
}
#Override
public void onBackPressed() {
if (drawerLayout.isDrawerOpen(GravityCompat.START)) {
drawerLayout.closeDrawer(GravityCompat.START);
} else super.onBackPressed();
count = fragmentManager.getBackStackEntryCount();
for (int i = 0; i < count; i++) {
fragmentManager.popBackStack();
}
toolbar.setNavigationIcon(R.drawable.ic_android_black_24dp);
}
private class CustomAdapter extends BaseAdapter {
#Override
public int getCount() {
return workoutsBackgrounds.length;
}
#Override
public Object getItem(int i) {
return null;
}
#Override
public long getItemId(int i) {
return 0;
}
#Override
public View getView(int i, View convertView, ViewGroup parent) {
View view1 = getLayoutInflater().inflate(R.layout.rowdata, null);
TextView name = view1.findViewById((R.id.workouts));
ImageView image = view1.findViewById((R.id.background));
name.setText(workoutsRoutines[i]);
image.setImageResource(workoutsBackgrounds[i]);
return view1;
}
}
#Override
public boolean onNavigationItemSelected(#NonNull MenuItem item) {
switch (item.getItemId()) {
case R.id.nav_profile:
fragment = new profileFragment();
fragmentManager = getSupportFragmentManager();
fragmentTransaction = fragmentManager.beginTransaction().replace(R.id.frameLayout, fragment).addToBackStack(null);
fragmentTransaction.commit();
toolbar.setNavigationIcon(R.drawable.ic_baseline_arrow_back_ios_24);
break;
case R.id.nav_custom_workouts:
fragment = new customWorkoutFragment();
fragmentManager = getSupportFragmentManager();
fragmentTransaction = fragmentManager.beginTransaction().replace(R.id.frameLayout, new customWorkoutFragment()).addToBackStack(null);
fragmentTransaction.commit();
toolbar.setNavigationIcon(R.drawable.ic_baseline_arrow_back_ios_24);
break;
}
item.setChecked(true);
drawerLayout.closeDrawer(GravityCompat.START);
return true;
}
}
needed to bring itemlist view to front
So basically i have created a recyclerview and added items into it and also created an adapter for the same
here is my adapter:
public class ExampleAdapter extends RecyclerView.Adapter<ExampleAdapter.ExampleViewHolder> {
private ArrayList<ExampleItem> mExampleList;
private OnItemClickListener mListener;
public interface OnItemClickListener {
void onItemClick(int position);
}
public void setOnItemClickListener(OnItemClickListener listener) {
mListener = listener;
}
public static class ExampleViewHolder extends RecyclerView.ViewHolder {
public ImageView mImageView;
public TextView mTextView1;
public TextView mTextView2;
public ExampleViewHolder(#NonNull View itemView, final OnItemClickListener listener) {
super(itemView);
mImageView = itemView.findViewById(R.id.imageView);
mTextView1 = itemView.findViewById(R.id.textView);
mTextView2 = itemView.findViewById(R.id.textView2);
itemView.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
if (listener != null) {
int position = getAdapterPosition();
if (position != RecyclerView.NO_POSITION) {
listener.onItemClick(position);
}
}
}
});
}
}
public ExampleAdapter(ArrayList<ExampleItem> exampleList) {
mExampleList = exampleList;
}
#NonNull
#Override
public ExampleViewHolder onCreateViewHolder(#NonNull ViewGroup parent, int viewType) {
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.example_item, parent, false);
ExampleViewHolder evh = new ExampleViewHolder(v, mListener);
return evh;
}
#Override
public void onBindViewHolder(#NonNull ExampleViewHolder holder, int position) {
ExampleItem currentItem = mExampleList.get(position);
holder.mImageView.setImageResource(currentItem.getmImageResource());
holder.mTextView1.setText(currentItem.getmText1());
holder.mTextView2.setText(currentItem.getmText2());
}
#Override
public int getItemCount() {
return mExampleList.size();
}
And this is my main activity:
private RecyclerView mRecyclerView;
private ExampleAdapter mAdapter;
private RecyclerView.LayoutManager mLayoutManager;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final ArrayList<ExampleItem> exampleList = new ArrayList<>();
exampleList.add(new ExampleItem(R.drawable.ic_android, "Line 1", "Line 2"));
exampleList.add(new ExampleItem(R.drawable.ic_audio, "Line 3", "Line 4"));
exampleList.add(new ExampleItem(R.drawable.ic_sun, "Line 5", "Line 6"));
exampleList.add(new ExampleItem(R.drawable.ic_android, "Line 7", "Line 8"));
exampleList.add(new ExampleItem(R.drawable.ic_audio, "Line 9", "Line 10"));
exampleList.add(new ExampleItem(R.drawable.ic_sun, "Line 11", "Line 12"));
exampleList.add(new ExampleItem(R.drawable.ic_android, "Line 13", "Line 14"));
exampleList.add(new ExampleItem(R.drawable.ic_audio, "Line 15", "Line 16"));
exampleList.add(new ExampleItem(R.drawable.ic_sun, "Line 17", "Line 18"));
mRecyclerView = findViewById(R.id.recyclerView);
mRecyclerView.setHasFixedSize(true); // set it as true if you know that your recyclerview will not change in size
mLayoutManager = new LinearLayoutManager(this);
mAdapter = new ExampleAdapter(exampleList);
mRecyclerView.setLayoutManager(mLayoutManager);
mRecyclerView.setAdapter(mAdapter);
mAdapter.setOnItemClickListener(new ExampleAdapter.OnItemClickListener() {
#Override
public void onItemClick(int position) {
exampleList.get(position);
}
});
}
}
My problem is basically i want to return the position of the item clicked in this recyclerview,
so that once i get the position, according to the position or the specific item clicked i can view it's content in a new activity.
In your ExampleViewHolder:
public static class ExampleViewHolder extends RecyclerView.ViewHolder {
public ImageView mImageView;
public TextView mTextView1;
public TextView mTextView2;
//add this
View view;
public ExampleViewHolder(#NonNull View itemView, final OnItemClickListener listener) {
super(itemView);
//set it here
view = itemView;
mImageView = itemView.findViewById(R.id.imageView);
mTextView1 = itemView.findViewById(R.id.textView);
.......
.......
In your adapter make a constructor that accepts a context
public class ExampleAdapter extends . ........
private Context context;
......
......
//constructor
public ExampleAdapter(.....,Context context){
.........
this.context = context;
}
Pass the context to the constructor, from your activity
//pass the context of the activity here
mAdapter = new ExampleAdapter(exampleList,getApplicationContext());
......
.....
In onBindViewHolder use the context to open new activity according to position:
#Override
public void onBindViewHolder(#NonNull ExampleViewHolder holder, int position) {
ExampleItem currentItem = mExampleList.get(position);
holder.mImageView.setImageResource(currentItem.getmImageResource());
holder.mTextView1.setText(currentItem.getmText1());
holder.mTextView2.setText(currentItem.getmText2());
//on click item
holder.view.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
if(position == 0){
//first item clicked
context.startActivity(new Intent(context, SomeActivity.class));
}else if(position == 1){
//second item clicked
context.startActivity(new Intent(context, SomeActivity.class));
}else if(position == 2){
//third item clicked
context.startActivity(new Intent(context, SomeActivity.class));
}.......
.......
}
});
}
I am updating my recyclerview by using LiveData as below:
viewModel = ViewModelProviders.of(getActivity()).get(MyViewModel.class);
viewModel.getPurchaseList().observe(getViewLifecycleOwner(), new Observer<List<ProductsObject>>() {
#Override
public void onChanged(#Nullable List<ProductsObject> productsObjects) {
adapter.submitList(productsObjects);
//adapter.notifyDataSetChanged();
}
});
And I am using a FloatActionButton to change the value of my MutableLiveData as below:
FloatingActionButton fab = view.findViewById(R.id.cart_fab);
fab.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
viewModel.setPurchasePrice(0, 101.2);
}
});
All the data gets changed and onChanged is called as expected, but it only updates my recyclerview when I enable the adapter.notifyDataSetChanged();
If I create a new ProductsObject inside the FAB and submit a new list, the recyclerview gets updated without calling adapter.notifyDataSetChanged(); as below:
FloatingActionButton fab = view.findViewById(R.id.cart_fab);
fab.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
//viewModel.setPurchaseAmount(0, 101.2);
ProductsObject prod = new ProductsObject("6666", 5, 152.2, "new product");
List<ProductsObject> prodList = new ArrayList<>();
prodList.add(prod);
adapter.submitList(prodList);
}
});
I appreciate if anyone could explain why.
Here is my adapter:
public class CartFragAdapter extends RecyclerView.Adapter<CartFragAdapter.CartFragViewHolder> {
private static final String TAG = "debinf PurchaseAdap";
private static final DiffUtil.ItemCallback<ProductsObject> DIFF_CALLBACK = new DiffUtil.ItemCallback<ProductsObject>() {
#Override
public boolean areItemsTheSame(#NonNull ProductsObject oldProduct, #NonNull ProductsObject newProduct) {
Log.i(TAG, "areItemsTheSame: old is "+oldProduct.getCode()+" ; new is "+newProduct.getCode());
return oldProduct.getCode().equals(newProduct.getCode());
}
#Override
public boolean areContentsTheSame(#NonNull ProductsObject oldProduct, #NonNull ProductsObject newProduct) {
Log.i(TAG, "areContentsTheSame: old is "+oldProduct.getPrice()+" ; new is "+newProduct.getPrice());
return oldProduct.getPrice() == newProduct.getPrice();
}
};
private AsyncListDiffer<ProductsObject> differ = new AsyncListDiffer<ProductsObject>(this, DIFF_CALLBACK);
#NonNull
#Override
public CartFragViewHolder onCreateViewHolder(#NonNull ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_purchase, parent, false);
return new CartFragViewHolder(view);
}
#Override
public void onBindViewHolder(#NonNull CartFragViewHolder holder, int position) {
final ProductsObject purchaseList = differ.getCurrentList().get(position);
holder.mCode.setText(purchaseList.getCode());
holder.mPrice.setText(String.valueOf(purchaseList.getPrice()));
holder.mDescription.setText(purchaseList.getDescription());
}
#Override
public int getItemCount() {
Log.i(TAG, "getItemCount");
return differ.getCurrentList().size();
}
public void submitList(List<ProductsObject> products){
Log.i(TAG, "submitList: products.size is "+products.size());
differ.submitList(products);
}
public class CartFragViewHolder extends RecyclerView.ViewHolder {
public TextView mCode, mPrice, mDescription;
public CartFragViewHolder(#NonNull View itemView) {
super(itemView);
mCode = (TextView) itemView.findViewById(R.id.item_productCode);
mPrice = (TextView) itemView.findViewById(R.id.item_productPrice);
mDescription = (TextView) itemView.findViewById(R.id.item_productDescription);
}
}
}
And here is my ViewModel:
public class MyViewModel extends ViewModel {
MutableLiveData<List<ProductsObject>> purchaseList = new MutableLiveData<>();
public LiveData<List<ProductsObject>> getPurchaseList() {
return purchaseList;
}
public void setPurchasePrice(int position, double price) {
List<ProductsObject> itemList = purchaseList.getValue();
if (itemList != null && itemList.get(position) != null) {
Log.i("debinf ViewModel", "setPurchaseAmount: "+itemList.get(position).getPrice());
itemList.get(position).setPrice(price);
purchaseList.postValue(itemList);
}
}
}
AsyncListDiffer saves only the reference of the list. This means that if you submit a modified list instead of submitting a new list, AsncListDiffer won't be able to detect any difference because both the previous list and the new list are referencing the same list with the same items.
To fix this you need to create a new list and new item. Change MyViewModel#setPurchasePrice as below:
public void setPurchasePrice(int position, double price) {
List<ProductsObject> itemList = purchaseList.getValue();
if (itemList != null && itemList.get(position) != null) {
List<ProductsObject> newList = new ArrayList<>();
for (int i = 0; i < itemList.size(); i++) {
ProductsObject prevProd = itemList.get(i);
if (i != position) {
newList.add(prevProd);
} else {
ProductsObject newProd = new ProductsObject(..., price, ...);
newList.add(newProd);
}
}
purchaseList.postValue(newList);
}
}
I'm working on my 1st android project, which uses a tab layout. I want to keep track of the active tab and change a textview present in the appbar (main activity).
Here is my main activity, tab manager, and a fragment
MAIN ACTIVITY
private static final String TAG = "MainActivity";
private SectionsPageAdapter mSectionsPageAdapter;
private ViewPager mViewPager;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mSectionsPageAdapter = new SectionsPageAdapter(getSupportFragmentManager());
mViewPager = (ViewPager) findViewById(R.id.container);
setupViewPager(mViewPager);
TabLayout tabLayout = (TabLayout) findViewById(R.id.Tabs);
tabLayout.setupWithViewPager(mViewPager);
tabLayout.getTabAt(0).setIcon(R.drawable.tab_rooms_24dp);
tabLayout.getTabAt(1).setIcon(R.drawable.tab_feed_24dp);
tabLayout.getTabAt(2).setIcon(R.drawable.tab_profile_24dp);
tabLayout.getTabAt(0).getIcon().setColorFilter(getResources().getColor(R.color.Accent), PorterDuff.Mode.SRC_IN);
tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
#Override
public void onTabSelected(TabLayout.Tab tab) {
tab.getIcon().setColorFilter(getResources().getColor(R.color.Accent),PorterDuff.Mode.SRC_IN);
}
#Override
public void onTabUnselected(TabLayout.Tab tab) {
tab.getIcon().clearColorFilter();
}
#Override
public void onTabReselected(TabLayout.Tab tab) {
}
});
}
private void setupViewPager(ViewPager viewPager){
SectionsPageAdapter adapter = new SectionsPageAdapter(getSupportFragmentManager());
adapter.addFragment(new Tab1Fragment(), "");
adapter.addFragment(new Tab2Fragment(), "");
adapter.addFragment(new Tab3Fragment(), "");
viewPager.setAdapter(adapter);
}
TAB MANAGER
private final List<Fragment> mFragmentList =new ArrayList<>();
private final List<String> mFragmentTitleList = new ArrayList<>();
public void addFragment(Fragment fragment, String title){
mFragmentList.add(fragment);
mFragmentTitleList.add(title );
}
public SectionsPageAdapter(FragmentManager fm) {
super(fm);
}
#Nullable
#Override
public CharSequence getPageTitle(int position) {
return mFragmentTitleList.get(position);
}
#Override
public Fragment getItem(int position) {
return mFragmentList.get(position);
}
#Override
public int getCount() {
return mFragmentList.size();
}
FRAGMENT
private static final String TAG = "Tab3Fragment";
#Nullable
#Override
public View onCreateView(#NonNull LayoutInflater inflater, #Nullable ViewGroup container, #Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_tab1,container,false);
return view;
}
I tried creating a variable in an abstract class then extending it into all three of these scripts which would be a simple solution but fragments dont seem to work well with extending, not to mention that probably isnt the most efficient method.
So I'm thinking the best method would be to simply handle it from the SectionsPageManager script?
Use addOnPageChangeListener on you pager.
mViewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
#Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
}
#Override
public void onPageSelected(int position) {
if (position == 1) {
setTitle("Tab 1");
} else if (position == 2)
{
setTitle("Tab 2");
}
else
{
setTitle("Home");
}
}
So I got it worked out and figured I'd come post the answer for anyone who may need it.
Not that the above answer sets the app title, not a TextView withing the appbar as stated in the question.
private static final String TAG = "MainActivity";
private SectionsPageAdapter mSectionsPageAdapter;
private ViewPager mViewPager;
private TextView activeTab;
#Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
activeTab = (TextView)findViewById(R.id.PageTitle);
mSectionsPageAdapter = new SectionsPageAdapter(getSupportFragmentManager());
mViewPager = (ViewPager) findViewById(R.id.container);
setupViewPager(mViewPager);
}
private void setupViewPager(ViewPager viewPager)
{
SectionsPageAdapter adapter = new SectionsPageAdapter(getSupportFragmentManager());
adapter.addFragment(new Tab1Fragment(), "");
adapter.addFragment(new Tab2Fragment(), "");
adapter.addFragment(new Tab3Fragment(), "");
viewPager.setAdapter(adapter);
viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
#Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { }
#Override
public void onPageSelected(int position)
{
switch (position){
case 0: activeTab.setText("text");
break;
case 1: activeTab.setText("better text");
break;
case 2: activeTab.setText("best text");
break;
}
}
#Override
public void onPageScrollStateChanged(int state) {
}
});
}
i want to populate a listView from the first listView that show all applications installed on the device, the second listView is on the second activity called "Blocked app" , my point is when i click on first listView items , the item should going to the second listView "Blocked App" for making an password interface thank uu and sorry for my english:
here is my MainActivity.Java code:
public class MainActivity extends AppCompatActivity {
private PackageManager packageManager=null;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final ListView userInstalledApps=(ListView)findViewById(R.id.installed_apps_list);
packageManager=getPackageManager();
final List<AppList>installedApp=getInstalledApps();
final AppAdapter installedAppAdapter=new AppAdapter(MainActivity.this,installedApp);
userInstalledApps.setAdapter(installedAppAdapter);
userInstalledApps.setOnItemClickListener(new AdapterView.OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
((ImageView)view.findViewById(R.id.ivlock)).setImageResource(R.drawable.unlocked);
// i shouuld write something here
}
});
}
private List<AppList> getInstalledApps()
{
List<AppList> resList=new ArrayList<AppList>();
List<PackageInfo> packs=getPackageManager().getInstalledPackages(0);
for(int i = 0; i < packs.size() ; i++)
{
PackageInfo pi= packs.get(i);
if ((isSystemPackage(pi)== false))
{
String appName=pi.applicationInfo.loadLabel(getPackageManager()).toString();
Drawable dIcon=pi.applicationInfo.loadIcon(getPackageManager());
resList.add(new AppList(appName,dIcon));
}
}
return resList;
}
private boolean isSystemPackage(PackageInfo pkgInfo)
{
return ((pkgInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) !=0) ? true : false;
}
public class AppAdapter extends BaseAdapter
{
private LayoutInflater layoutInflater;
private List<AppList> listExtStorage;
public AppAdapter(Context context,List<AppList> customListView)
{
layoutInflater=(LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
listExtStorage=customListView;
}
#Override
public int getCount() {
return listExtStorage.size();
}
#Override
public Object getItem(int position) {
return position;
}
#Override
public long getItemId(int position) {
return position;
}
#Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder listViewHolder;
if(convertView==null)
{
listViewHolder=new ViewHolder();
convertView=layoutInflater.inflate(R.layout.installed_app_list,parent, false);
listViewHolder.AppNameInList=(TextView)convertView.findViewById(R.id.app_name_in_list);
listViewHolder.AppIconInList=(ImageView)convertView.findViewById(R.id.apps_icon);
convertView.setTag(listViewHolder);
}
else
{
listViewHolder=(ViewHolder)convertView.getTag();
}
listViewHolder.AppNameInList.setText(listExtStorage.get(position).getName());
listViewHolder.AppIconInList.setImageDrawable(listExtStorage.get(position).getIcon());
return convertView;
}
}
static class ViewHolder
{
TextView AppNameInList;
ImageView AppIconInList;
}
public class AppList
{
private String name;
Drawable icon;
public AppList(String name, Drawable icon)
{
this.name=name;
this.icon=icon;
}
public String getName()
{
return name;
}
public Drawable getIcon()
{
return icon;
}
}
}