2011-06-14 8 views
0

나는 두 개의리스트 뷰, 오른쪽과 왼쪽의 타블렛 레이아웃을 가지고있다. 그룹 (왼쪽 목록의 항목)을 클릭하면 그룹이 다른 목록 (groupsList)에 표시됩니다. 이제 특정 영역에서 groupslist를 클릭하면 다른 레이아웃을 표시해야합니다. 그래서 어떻게 진행하나요?안드로이드 타블렛의 목록보기

아래는 내 코드입니다 : - 세 번째 목록을 표시하는 측면에서

package com.list.viewer; 

import android.app.Activity; 
import android.content.Context; 
import android.os.Bundle; 
import android.view.LayoutInflater; 
import android.view.View; 
import android.view.ViewGroup; 
import android.widget.AdapterView; 
import android.widget.BaseAdapter; 
import android.widget.ImageView; 
import android.widget.ListView; 
import android.widget.TextView; 
import android.widget.AdapterView.OnItemClickListener; 

public class HealthPlan extends Activity 
{ 

private String[] list1 = { "Group", "Opportunities", "Contacts", "Activities" , "Quotes"}; 
private String[] list2 = { "", "", "", "" , ""}; 

private Integer[] imgid = {R.drawable.accounts,R.drawable.s,R.drawable.contacts, 
     R.drawable.activities ,R.drawable.s}; 

static final Integer[] aimgid = {R.drawable.activities_60,R.drawable.activities_60,R.drawable.activities_60, 
    R.drawable.activities_60,R.drawable.activities_60}; 

static final String[] a1 = new String[] {"1-96XO56","1-96XOPL","1-96XOMR","1-96XOKM"}; 

static final String[] a2 = new String[] {"Open","Closed","Cancelled","Open"}; 

static final Integer[] cimgid = {R.drawable.contacts_60,R.drawable.contacts_60,R.drawable.contacts_60, 
    R.drawable.contacts_60 ,R.drawable.contacts_60}; 

static final String[] c1 = new String[] {"Denning","Guido","Castro","Heath"}; 

static final String[] c2 = new String[] {"[email protected]","","","[email protected]"}; 

static final Integer[] gimgid = {R.drawable.accounts_60,R.drawable.accounts_60,R.drawable.accounts_60, 
    R.drawable.accounts_60 ,R.drawable.accounts_60}; 

static final String[] g1 = new String[] {"La Maison Blanche Bakery","(NSCC) FRONTIER INFORMATI", 
    "american Diamond Tool,Inc","OCH Test 20100831"}; 

static final String[] g2 = new String[] {"PRVS - Private Sector","PBLS - Public Sector","PRVS - Private Sector","NATL - National Account"}; 

static final Integer[] qimgid = {R.drawable.health,R.drawable.health,R.drawable.health, 
    R.drawable.health,R.drawable.health}; 

static final String[] q1 = new String[] {"1-7LY9JK","1-7GRMRO","1-7FCJBR","1-7GRMP4"}; 

static final String[] q2 = new String[] {"In-Progress","Created","Install In Progress", 
    "Installed"}; 

static final Integer[] oimgid = {R.drawable.health,R.drawable.health,R.drawable.health, 
    R.drawable.health,R.drawable.health}; 

static final String[] o1 = new String[] {"Long Term Care","HMO Blue Choice Value", 
    "Drug","Long Term Care"}; 

static final String[] o2 = new String[] {"New Business - Exclusive", 
    "Win Exclusive","New Business - Nonexclusive","Change Product/Service"}; 

private ListView lister1; 
private ListView lister2; 

@Override 
public void onCreate(Bundle savedInstanceState) 
{ 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.main); 

    lister1 = (ListView) findViewById(R.id.ListView1); 
    lister2 = (ListView) findViewById(R.id.ListView2); 

    ItemsAdapter itemsAdapter = new ItemsAdapter(HealthPlan.this, 
      R.layout.row, list1 , list2,imgid); 
    lister1.setAdapter(itemsAdapter); 

    lister2.setAdapter(new ItemsAdapter(HealthPlan.this, 
      R.layout.row, g1 , g2,gimgid)); 

    lister2.setOnItemClickListener(new OnItemClickListener() 
    { 
     @Override 
     public void onItemClick(AdapterView<?> arg0, View arg1, int position, 
       long arg3) 
     { 


     } 

    }); 

    lister1.setOnItemClickListener(new OnItemClickListener() 
    { 
     @Override 
     public void onItemClick(AdapterView<?> arg0, View arg1, 
       int position, long arg3) 
     { 
      String[] lister = null; 
      String[] lister1 = null; 
      Integer[] image = null; 
      switch (position) 
      { 
      case 0: 
       lister = g1; 
       lister1 = g2; 
       image = gimgid; 
       break; 
      case 1: 
       lister = o1; 
       lister1 = o2; 
       image = oimgid; 
       break; 
      case 2: 
       lister = c1; 
       lister1 = c2; 
       image = cimgid; 
       break; 
      case 3: 
       lister = a1; 
       lister1 = a2; 
       image = aimgid; 
       break; 
      case 4: 
       lister = q1; 
       lister1 = q2; 
       image = qimgid; 
       break; 
      default: 
       lister = g1; 
       lister1 = g2; 
       image = gimgid; 
      } 
      lister2.setAdapter(new ItemsAdapter(HealthPlan.this, 
        R.layout.row, lister , lister1 ,image)); 
     } 
    }); 
} 

private class ItemsAdapter extends BaseAdapter 
{ 
    String[] items; 
    String[] items1; 
    Integer[] images; 

    public ItemsAdapter(Context context, int textViewResourceId,String[] items,String[] items1,Integer[] images) 
    { 
     this.items = items; 
     this.items1 = items1; 
     this.images=images; 
    } 

    @Override 
    public View getView(final int position, View convertView, ViewGroup parent) 
    { 
     TextView mDescription; 
     TextView mDescription1; 
     View view = convertView; 
     ImageView image; 

     if (view == null) 
     { 
      LayoutInflater vi = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); 
      view = vi.inflate(R.layout.row, null); 
     } 

     image = (ImageView) view.findViewById(R.id.icon); 
     mDescription = (TextView) view.findViewById(R.id.tt1); 
     mDescription1 = (TextView) view.findViewById(R.id.tt2); 
     mDescription.setText(items[position]); 
     mDescription1.setText(items1[position]); 
     image.setImageResource(images[position]); 
     return view; 
    } 

    public int getCount() 
    { 
     return items.length; 
    } 

    public Object getItem(int position) 
    { 
     return position; 
    } 

    public long getItemId(int position) 
    { 
     return position; 
    } 
} 

}

답변

0

, 그것은 실제로 아주 쉽게 할, 그리고 당신의 패턴에 맞게. 레이아웃 파일에서 세 번째 목록을 정의하지만 사라지는 가시성을 설정하면 아직 볼 수 없습니다. 이제 두 번째 목록에서 클릭이 발생하면 세 번째 목록의 표시 여부를 설정하여 표시되도록 할 수 있습니다.

Lister.setVisibility (View.VISIBLE) ; 
관련 문제