Skip to main content

Posts

android working with activities history stack

never override the default behavior and instead if you have to do it for a particular activity then  the following line is more than enough intent . setFlags ( Intent . FLAG_ACTIVITY_CLEAR_TOP ); or after you start activity  then call finish(); example Intent main = new Intent(LoginActivity.this, MainActivity.class); startActivity(main); finish();

android list view keep only the selected item marked

here i found a very useful solution http://www.michenux.net/android-listview-highlight-selected-item-387.html <ListView         android:id = "@android:id/list"         android:layout_width = "fill_parent"         android:layout_height = "wrap_content"         android:choiceMode = "singleChoice" > </ListView > Then, you need to create a selector. This is where you will configure colors for each defined state. The selected file is in res/drawable directory. <?xml   version = "1.0"   encoding = "utf-8" ?> <selector   xmlns:android = "http://schemas.android.com/apk/res/android"     android:exitFadeDuration = "@android:integer/config_mediumAnimTime" >     <item   android:drawable = "@android:color/holo_orange_dark"   android:state_pressed = "true" />     <item   android:drawable = "@android:color/holo_green_l...

Android custom searchable ListView with Custom Filter

The idea is on how to implement the custom filter in a good way free of bugs. In this example i ave a list of materials and i am supposed to select from it and search inside it as well. The filter here is anonymous class inside the materials adapter. The adapter class package com.dash.util; import java.util.ArrayList; import java.util.List; import com.dash.patientmaterials.R; import android.content.Context; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.Filter; import android.widget.Filterable; import android.widget.TextView; /** * * @author melsonbati@hotmail.com * */ public class MaterialsAdapter extends ArrayAdapter<MaterialItem> implements Filterable{ private List<MaterialItem> allMaterials; private List<MaterialItem> filterdMaterials; View row; int resLayout; Context context; public MaterialsAdapter(Context context, int layoutId, L...