1. Download our Official Android App: Forums for Android!

Apps Helppp

Discussion in 'Android Development' started by aattaa, Feb 14, 2011.

  1. aattaa

    aattaa Lurker
    Thread Starter
    Rank:
    None
    Points:
    5
    Posts:
    9
    Joined:
    Feb 12, 2011

    Feb 12, 2011
    9
    0
    5
    I cant show image. What the is problem?

    import java.util.ArrayList;
    import java.util.HashMap;
    import java.util.List;
    import java.util.Map;

    import com.enea.takk.R;
    import com.enea.takk.database.DBManager;
    import com.enea.takk.services.WordListAdapter;

    import android.content.Intent;
    import android.os.Bundle;
    import android.util.Log;
    import android.view.View;
    import android.view.Window;
    import android.widget.AdapterView;
    import android.widget.ExpandableListAdapter;
    import android.widget.ExpandableListView;
    import android.widget.SimpleExpandableListAdapter;
    import android.widget.AdapterView.OnItemClickListener;
    import android.widget.ExpandableListView.OnChildClickListener;

    public class Categories extends BaseActivity {

    private static final String NAME = "NAME";

    BaseActivity b = new BaseActivity();
    private ExpandableListAdapter mAdapter;


    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    /*
    * show menu
    */
    requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
    setContentView(R.layout.expandable_list_layout);
    customizeTitleBar("Kategorier", null);
    setVisibilityToButton(R.id.left_button, visibilityGone);
    setVisibilityToButton(R.id.right_button, visibilityGone);

    DBManager db = new DBManager(getApplicationContext());

    List<String> header = db.selectAllCategories();
    List<Map<String, String>> groupData = new ArrayList<Map<String, String>>();
    final List<List<Map<String, String>>> childData = new ArrayList<List<Map<String, String>>>();

    for (String category : header) {
    Map<String, String> curGroupMap = new HashMap<String, String>();
    groupData.add(curGroupMap);
    curGroupMap.put(NAME, category);
    List<String> categoryWords = db.selectWordsFromCategory(category);

    List<Map<String, String>> children = new ArrayList<Map<String, String>>();
    for (String word : categoryWords) {
    Map<String, String> curChildMap = new HashMap<String, String>();
    children.add(curChildMap);

    curChildMap.put(NAME, word);
    }
    childData.add(children);
    }

    mAdapter = new SimpleExpandableListAdapter(
    getApplicationContext(),
    groupData,
    R.layout.simple_expandable_list_item_1,
    new String[] { NAME },
    new int[] { R.id.header_text1 },
    childData,
    R.layout.simple_expandable_list_item_2,
    new String[] { NAME },
    new int[] { R.id.text1 }
    );

    final ExpandableListView lv = (ExpandableListView)findViewById(R.id.list);

    lv.setAdapter(mAdapter);

    lv.setOnChildClickListener(new OnChildClickListener() {



    public boolean onChildClick (ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {

    Intent intent = new Intent(getApplicationContext(), ShowImage.class);
    intent.putExtra("selectedItem", childData.get(groupPosition).toString());
    Log.i("SELECTED ITEM", "" + groupPosition );
    startActivity(intent);

    return false;
    }
    });


    }
     

    Advertisement

Share This Page

Loading...