Friday, October 14, 2011

Android Debug Certificate expired

[meet error in eclipse]
"Error generating final archive: Debug Certificate expired on 11-9-21 12:25"

rm ~/.android/debug.keystore

Saturday, October 8, 2011

2 lines text in single choice listview (Android)

1, single choice
2, two lines text align center in vertical 
3, some items own one line text only, and it should also stay in center of vertical.
4, radio button should be checked when tap any position of the list item (radio button should not response users' click directly)

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout android:id="@+id/relativeLayout1"
     android:layout_width="fill_parent" android:layout_height="wrap_content"    
     <LinearLayout android:layout_centerVertical="true"
         android:layout_width="fill_parent" android:layout_height="wrap_content"
         android:orientation="vertical" android:gravity="center_vertical">
         <TextView android:layout_width="wrap_content"
              android:layout_height="wrap_content" android:id="@+id/tv_MainText"
              android:textAppearance="?android:attr/textAppearanceMedium" />
         <TextView android:layout_width="wrap_content"
              android:layout_height="wrap_content" android:id="@+id/tv_SubText"
              android:textAppearance="?android:attr/textAppearanceSmall" />

     <RadioButton android:layout_height="wrap_content"
         android:id="@+id/rb_Choice" android:layout_width="wrap_content"  android:layout_centerVertical="true"
         android:layout_alignParentRight="true" android:gravity="center_vertical"
         android:focusable="false"  android:clickable="false"


java code:
 public void onCreate(Bundle savedInstanceState) {
        m_this = this;
        //begin init test data
        final ArrayList<HashMap<String, Object>> m_data = new ArrayList<HashMap<String, Object>>();
        HashMap<String, Object> map1 = new HashMap<String, Object>();
        map1.put("maintext", "Large text 1");
        map1.put("subtext", "small text 1A");        
        HashMap<String, Object> map2 = new HashMap<String, Object>();
        map2.put("maintext", "Large text 2");// no small text of this item!
        HashMap<String, Object> map3 = new HashMap<String, Object>();
        map3.put("maintext", "Large text 3");
        map3.put("subtext", "small text 3");
        for (HashMap<String, Object> m :m_data) //make data of this view should not be null (hide )
m.put("checked", false);
      //end init data
        final ListView lv = (ListView) m_this.findViewById(;
        final SimpleAdapter adapter = new SimpleAdapter(m_this,
                new String[] {"maintext", "subtext", "checked"}, 
                new int[] {,,}); 
        adapter.setViewBinder(new ViewBinder()
        public boolean setViewValue(View view, Object data, String textRepresentation)
if (data == null) //if 2nd line text is null, its textview should be hidden 
return true;
return false;


        // Bind to our new adapter.
        lv.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> arg0, View v, int arg2, long arg3) {
RadioButton rb = (RadioButton) v.findViewById(;
if (!rb.isChecked()) //OFF->ON
for (HashMap<String, Object> m :m_data) //clean previous selected
m.put("checked", false);
m_data.get(arg2).put("checked", true);
        //show result
        ((Button)m_this.findViewById( OnClickListener() {
public void onClick(View v) {
int r = -1;
for (int i = 0; i < m_data.size(); i++) //clean previous selected
HashMap<String, Object> m = m_data.get(i);
Boolean x = (Boolean) m.get("checked");
if (x == true)
r = i;
break; //break, since it's a single choice list
new AlertDialog.Builder(m_this).setMessage("you selected:"+r).show();