Click here to Skip to main content
15,893,487 members
Home / Discussions / Android
   

Android

 
QuestionDesign SearchBox programatically in android Pin
izharcse3-Jan-14 7:25
izharcse3-Jan-14 7:25 
AnswerRe: Design SearchBox programatically in android Pin
tabrej5-Jan-14 4:59
tabrej5-Jan-14 4:59 
AnswerRe: Design SearchBox programatically in android Pin
Member 1043479721-Jan-14 16:23
professionalMember 1043479721-Jan-14 16:23 
QuestionCode to Design programatically a dynamic Gridview with row and column Pin
izharcse3-Jan-14 7:22
izharcse3-Jan-14 7:22 
QuestionConsume WCF Service on Android Pin
dalewill31-Dec-13 4:17
dalewill31-Dec-13 4:17 
AnswerRe: Consume WCF Service on Android Pin
tabrej5-Jan-14 5:03
tabrej5-Jan-14 5:03 
AnswerRe: Consume WCF Service on Android Pin
Giannakakis Kostas7-Jan-14 1:58
professionalGiannakakis Kostas7-Jan-14 1:58 
QuestionHow to speed up the populating of listview Pin
Member 947380924-Dec-13 18:26
Member 947380924-Dec-13 18:26 
Hi,
I am populating my listview from Sqlite (sometime also from DataTable)
1. when the data is huge its very slow ?
2. how to have filter for this with high speed ?(same as contact list )

Thanks in advanced !
For filtering i have seen this code :

_adapter.Filter.InvokeFilter(_inputSearch.Text);


but just work for one column :
_adapter = new ArrayAdapter<string>(this, Resource.Layout.list_item, Resource.Id.product_name, products);

No USE At ALL !!!!

my code :

protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Create your application here
            SetContentView(Resource.Layout.HesabList);

            progress = ProgressDialog.Show(this, "", "Loading ...");
            progress.SetProgressStyle(ProgressDialogStyle.Spinner);
            progress.Indeterminate = true;
            new Thread(new ThreadStart(delegate
            {
                _btnUpdate = FindViewById<Button>(Resource.Id.UpdateHesabList);
                _btnUpdate.Click += new EventHandler(_btnUpdate_Click);
                gvHesab = FindViewById<ListView>(Resource.Id.gvHesabList);
                gvHesab.ItemClick += new EventHandler<AdapterView.ItemClickEventArgs>(gvHesab_ItemClick);
                isTarafHesab = Intent.GetBooleanExtra("IsTarafHesab", false);
                txtSearchHesabList = (EditText)FindViewById(Resource.Id.txtSearchHesabList);
                txtSearchHesabList.TextChanged += new EventHandler<Android.Text.TextChangedEventArgs>(txtSearchHesabList_TextChanged);
                txtSearchHesabList.Gravity = GravityFlags.Right;

                Looper.Prepare();
                File dbtest = new File(clsBase.SqliteDBPath);
                
                if (!dbtest.Exists() )
                {

                    if (clsBase.HasInternetConnection(this))
                        createDbSqlite();
                    else
                    {
                        MessageBoxAndroid.Show(this, "Connect to Internet First !");
                        Finish();
                    }
                }
                else
                {
                     fillListView();
                 }

                RunOnUiThread(() => progress.Dismiss()); 
           })).Start();
            
        }


private void fillGridView()
        {
            try
            {  
                SQLiteDatabase db = OpenOrCreateDatabase("test.db", FileCreationMode.WorldReadable, null);

                ICursor cursors = db.RawQuery("select Moen, Hesab, opab, Coab,(select count(*) from tbl_Hest b  where a._id >= b._id) as _id,Id  from tbl_Hest a", null);
                
                String[] from = Resources.GetStringArray(Resource.Array.gvHesabHeader);

                int[] to = { Resource.Id.txt_HesabListGrid_Heen,
                             Resource.Id.txt_HesabListGrid_Heol ,Resource.Id.txt_HesabListGrid_Heb,
                             Resource.Id.txt_HesabListGrid_Coab,Resource.Id.txt_HesabListGrid_Row,Resource.Id.txt_HesabListGrid_Id};
                RunOnUiThread(() =>
               {
                   SimpleCursorAdapter _HesabGridAdapter = new HesabListGridview(this, Resource.Layout.HesabListGrid, cursors, from, to);
                    
                       gvHesab.Adapter = _HesabGridAdapter;
               });
                
                setListViewHeightBasedOnChildren(gvHesab);//بخورد Scroll برای حالتی که کل صفحه 
                gvHesab.TextFilterEnabled = true;
                
                EditText txtSearchHesabList = (EditText)FindViewById(Resource.Id.txtSearchHesabList);
                txtSearchHesabList.TextChanged += new EventHandler<Android.Text.TextChangedEventArgs>     
                (txtSearchHesabList_TextChanged);
                 
              
            }
            catch (Exception ex)
            {
                
            }
        }



    class HesabListGridview : SimpleCursorAdapter
    {
        ICursor c;
        //MatrixCursor cur;
        Context context;
        Activity activity;
        int idS;
        public HesabListGridview(Context context, int layout, ICursor c, string[] from, int[] to)
            : base(context, layout, c, from, to)
        {
            this.c = c; 
            this.context = context;
            this.activity = (Activity)context;

        }
        bool isFirst = true;
        public static int dtRowCount = 0;
        int CountRepeated = 0;
        public override Filter Filter
        {
            get
            {
                return base.Filter;
            }
        }
        public override IFilterQueryProvider FilterQueryProvider
        {
            get
            {
                return base.FilterQueryProvider;
            }
            set
            {
                base.FilterQueryProvider = value;
            }
        }
        public override View GetView(int position, View convertView, ViewGroup parent)
        {

            if (convertView == null)
                convertView = View.Inflate(context, Resource.Layout.HesabListGrid, null);
            View row = convertView;
            try
            {

                c.MoveToPosition(position);
                TextView txtHesabGrid_Coni = (TextView)convertView.FindViewById(Resource.Id.txt_HesabListGrid_Hesoen);
                TextView txtHesabGrid_Bde = (TextView)convertView.FindViewById(Resource.Id.txt_HesabListGrid_Hesol);
                TextView txtHesabGrid_Nab = (TextView)convertView.FindViewById(Resource.Id.txt_HesabListGrid_Heab);
                TextView txtHesabGrid_Cosab = (TextView)convertView.FindViewById(Resource.Id.txt_HesabListGrid_Coab);
                TextView txtHesabGrid_Row = (TextView)convertView.FindViewById(Resource.Id.txt_HesabListGrid_Row);
                TextView txtHesabGrid_Id = (TextView)convertView.FindViewById(Resource.Id.txt_HesabListGrid_Id);



                txtHesabGrid_Coni.SetText(c.GetString(c.GetColumnIndex("Hen")), TextView.BufferType.Normal);



                txtHesabGrid_Bde.SetText(c.GetString(c.GetColumnIndex("Hl")), TextView.BufferType.Normal);


                txtHesabGrid_Nab.SetText(c.GetString(c.GetColumnIndex("Heb")), TextView.BufferType.Normal);

                txtHesabGrid_Cosab.SetText(c.GetString(c.GetColumnIndex("Coab")), TextView.BufferType.Normal);

                txtHesabGrid_Row.SetText(c.GetInt(c.GetColumnIndex("_id")).ToString(), TextView.BufferType.Normal);

                txtHesabGrid_Id.SetText(c.GetString(c.GetColumnIndex("Id")), TextView.BufferType.Normal);
                txtHesabGrid_Id.Visibility = ViewStates.Gone;
                //txtHesabGrid_Id.Visibility = ViewStates.Invisible;
                if (position % 2 == 0)
                {

                    convertView.SetBackgroundColor(Android.Graphics.Color.ParseColor("#6bcdfb"));
                }
                else
                {
                    convertView.SetBackgroundColor(Android.Graphics.Color.ParseColor("#2cb8de"));
                }
                CountRepeated++;
               // MessageBoxAndroid.Show(context, CountRepeated.ToString()  + "\n" + dtRowCount.ToString());
                if (17 == CountRepeated)
                {
                    isFirst = false;
                }
                if (isFirst)
                {
                    
                    HorizontalScrollView hv = (HorizontalScrollView)activity.FindViewById(Resource.Id.scrollHesabListGrid);
                    hv.FullScroll(FocusSearchDirection.Left);

                }
            }
            catch (Exception ex)
            {
                    }

            //hv.ScrollTo(hv.Right + 80, hv.Top);
            return (row);
        }




    }
}

QuestionSearch Interface Pin
Member 935370223-Dec-13 1:39
Member 935370223-Dec-13 1:39 
AnswerRe: Search Interface Pin
tabrej5-Jan-14 5:05
tabrej5-Jan-14 5:05 
QuestionXML and HTML parsing in one Activity Pin
Kroshandowski22-Dec-13 5:22
Kroshandowski22-Dec-13 5:22 
QuestionConvert to C# Pin
Member 947380918-Dec-13 10:15
Member 947380918-Dec-13 10:15 
AnswerRe: Convert to C# Pin
Richard Deeming19-Dec-13 2:11
mveRichard Deeming19-Dec-13 2:11 
Questionbackground service/process Pin
Bhagyashree Chaudhari - Member 1047363417-Dec-13 23:05
Bhagyashree Chaudhari - Member 1047363417-Dec-13 23:05 
AnswerRe: background service/process Pin
tabrej5-Jan-14 5:11
tabrej5-Jan-14 5:11 
Questionpost data to database using KSoap2 Pin
Barun4214-Dec-13 0:13
Barun4214-Dec-13 0:13 
AnswerRe: post data to database using KSoap2 Pin
Member 1041739716-Dec-13 1:30
Member 1041739716-Dec-13 1:30 
QuestionWherefore art thou, ARM? Pin
hairy_hats13-Dec-13 1:11
hairy_hats13-Dec-13 1:11 
Answerc# methods Pin
Member 104521337-Dec-13 20:25
Member 104521337-Dec-13 20:25 
Questionc# methods Pin
Member 104521337-Dec-13 20:24
Member 104521337-Dec-13 20:24 
AnswerRe: c# methods Pin
Richard MacCutchan7-Dec-13 21:33
mveRichard MacCutchan7-Dec-13 21:33 
AnswerRe: c# methods Pin
Albert Holguin13-Dec-13 4:58
professionalAlbert Holguin13-Dec-13 4:58 
NewsIt's Learn Android Month Pin
Brian Aberle5-Dec-13 6:34
professionalBrian Aberle5-Dec-13 6:34 
QuestionDelete a single note from list view Pin
Member 104393335-Dec-13 3:08
Member 104393335-Dec-13 3:08 
QuestionRe: Delete a single note from list view Pin
thatraja5-Dec-13 4:03
professionalthatraja5-Dec-13 4:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.