0

当我单击 listfragment 特定数据时,该数据必须显示在第二个片段的自定义列表视图中。意味着单击的项目必须添加到第二个片段中。但列表视图没有出现..

public class MyPlayerFrag extends Fragment  {

    Context context;    
    CustomDetailAdapter adapter;

    ListView list;
    LayoutInflater mInflater;
    ArrayList<String> title =new ArrayList<String>();   
    ArrayList<String> description =new ArrayList<String>(); 

    @Override
        public void onAttach(Activity activity) {
            // TODO Auto-generated method stub

        super.onAttach(activity);

    }


    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        // TODO Auto-generated method stub

        View v = inflater.inflate(R.layout.detail, container,false);
            list = (ListView)v.findViewById(R.id.listview);    

            return v;

    }

    public void detailData(Context applicationContext,ArrayList<String> data1,ArrayList<String> data2){

                this.title =data1;
        this.description=data2;

            CustomDetailAdapter adapter =new CustomDetailAdapter(context, title, description);
            list.setAdapter(adapter);


here am getting output like in log System.out.println(" title::"+ title);
as[keyboard1,keyboard2]


    }


    }

    public class CustomDetailAdapter extends BaseAdapter {
        Context context ;
        ArrayList<String> items= null;
        ArrayList<String> items1= null;     

        public CustomDetailAdapter(Context context,ArrayList<String> items, ArrayList<String> items1) {

            this.context =context;
            // TODO Auto-generated constructor stub         
            this.items = items;
        this.items1 = items1;




        }

        /*private view holder class*/
     private class ViewHolder {      
            TextView txtTitle;
            TextView txtDesc;

        }




     public View getView(final int position, View convertView, ViewGroup parent) {
            // TODO Auto-generated method stub



         ViewHolder holder = null;  

         System.out.println("am in getview");        

          mInflater = (LayoutInflater)
                    context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

            if (convertView == null) {

                    convertView = mInflater.inflate(R.layout.player, null); 
                    holder = new ViewHolder();

                    holder.txtTitle = (TextView) convertView.findViewById(R.id.title);                  
                   holder.txtDesc = (TextView) convertView.findViewById(R.id.desc);
                    convertView.setTag(holder);                     

            } else {
                 holder = (ViewHolder) convertView.getTag();
            }


                holder.txtTitle.setText(items1.get(position));          
               holder.txtDesc.setText(items.get(position));

        return convertView;

        }



        @Override
        public Object getItem(int position) {
            return items;
        }

    @Override
    public int getCount() {
        // TODO Auto-generated method stub
        return 0;
    }

    @Override
    public long getItemId(int arg0) {
        // TODO Auto-generated method stub
        return 0;
    }



    }
4

0 回答 0