Sam Mettenmeyer

Sam Mettenmeyer

  • NA
  • 108
  • 11.3k

ListView item as a progress bar

Nov 19 2019 8:57 AM

Hello guys,

I was wondering if someone can maybe help me with the following intent:

I created an app which simply displays a table. It shows a table head and beyond that a list view which contains several items.
Is it possible, that if one clicks on one of these items, a progress bar is shown which loads smoothely in a certain time interval (lets say 30 seconds) from left to right?

Please see my screenshot below, maybe it's easier to understand what I am trying to do:

 
 
Finally, I don't know if it helps, but let me attach some code as well. I shortened it a little, if something is missing for understanding (like the list class) or if I removed to much, please let me know:
 
  1. public class TableActivity : Activity  
  2. {  
  3.     ListView lv;  
  4.     ListAdapter adapter = null;  
  5.     protected override void OnCreate(Bundle bundle)  
  6.     {  
  7.         base.OnCreate(bundle);  
  8.         //...  
  9.         lv = FindViewById<ListView>(Resource.Id.geraeteListView);  
  10.         adapter = new ListAdapter(this, Resource.Layout.List, geraeteliste.CurrentGeraeteliste, Intent.GetStringExtra("ServerIP"))  
  11.         {  
  12.             parentActivity = this  
  13.         };  
  14.         lv.Adapter = adapter;  
  15.     }  
  16.   
  17.     private async void OnItemClick(object sender, AdapterView.ItemClickEventArgs e)  
  18.     {  
  19.         if (geraeteliste.CurrentGeraeteliste[e.Position].bespielt == "J"return;  
  20.         //…  
  21.         await Task.Delay(0);  
  22.     }   
  23. }  
  1. public class ListAdapter : ArrayAdapter  
  2. {  
  3.     //...  
  4.     public override View GetView(int position, View convertView, ViewGroup parent)  
  5.     {  
  6.         View v = convertView;  
  7.         if (v == null)  
  8.         {  
  9.             LayoutInflater inflater = (LayoutInflater)Context.GetSystemService(Context.LayoutInflaterService);  
  10.             v = inflater.Inflate(Resource.Layout.List, parent, false);  
  11.         }  
  12.         //...  
  13.         v.FindViewById<ImageView>(Resource.Id.typeImageView).SetImageResource(Resource.Drawable.Icon);  
  14.         v.FindViewById<TextView>(Resource.Id.numberTextView).Text = Geraetelist[position].geraeteplatz;  
  15.         v.FindViewById<TextView>(Resource.Id.descriptionTextView).Text = Geraetelist[position].geraeteinformation;  
  16.         ImageView iv = v.FindViewById<ImageView>(Resource.Id.bspImageView);  
  17.         iv.SetImageResource(Geraetelist[position].bespielt == "N" ? Resource.Drawable.greenPoint : Resource.Drawable.redPoint);  
  18.         //…  
  19.         return v;          
  20.     }  
  21. }  

Can anyone maybe give me a short hint or something? How can I implement such a progress bar for every item on click?^^ Would be really happy for every helping effort.

Thanks in advance for every answer,

Best regards

 

Answers (2)