@Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { this.inflater = inflater; if (diseaseview != null) container.removeAllViews(); diseaseview = inflater.inflate(R.layout.fragment_symptomdisease, container, false); InitWidth(diseaseview); lcontent = (LinearLayout) diseaseview.findViewById(R.id.lcontainer); btjianjie = (Button) diseaseview.findViewById(R.id.jianjie); btdescription = (Button) diseaseview.findViewById(R.id.description); btjianjie.setEnabled(true); btdescription.setEnabled(true); btjianjie.setOnClickListener(this); btdescription.setOnClickListener(this); if (data.getType() == Constants.ZHENGZHUANG) { btdescription.setText("¿ÉÄܼ²²¡"); } else { btdescription.setText("°éËæÖ¢×´"); } onjianjie(); return diseaseview; }
public void ondescription() { if (data.getType() == Constants.ZHENGZHUANG) { LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT, 1); ListView diseaselist = new ListView(getActivity()); diseaselist.setAdapter( new BaseAdapter() { private TextView listitem_name = null; private TextView listitem_keshi = null; private Button listitem_guahao = null; private TextView listitem_description = null; private String[] items = data.getDetaildata().split(","); @Override public int getCount() { return items.length; } @Override public Object getItem(int position) { return getItem(position); } @Override public long getItemId(int position) { return position; } @Override public View getView(int position, View convertView, ViewGroup parent) { View view = convertView; if (view == null) view = LayoutInflater.from(getActivity()).inflate(R.layout.listitem_symptom, null); listitem_name = (TextView) view.findViewById(R.id.listitem_name); listitem_keshi = (TextView) view.findViewById(R.id.listitem_keshi); listitem_guahao = (Button) view.findViewById(R.id.listitem_guahao); listitem_description = (TextView) view.findViewById(R.id.listitem_description); String item[] = items[position].split(":"); listitem_name.setText(item[0]); listitem_keshi.setText(item[1]); listitem_description.setText(item[2]); listitem_guahao.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(getActivity(), MainActivity.class); intent.putExtra("intent", "AppointmentFragment"); startActivity(intent); } }); return view; } }); diseaselist.setOnItemClickListener( new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { // Intent intent=new Intent(getActivity(),MainActivity.class); // intent.putExtra("intent","OndutyFragment"); // startActivity(intent); // FragmentTransaction tran=getFragmentManager().beginTransaction(); // Fragment temp=new OndutyFragment(); // tran.replace(R.id.lcontainer,temp).addToBackStack(null).commit(); } }); diseaselist.setLayoutParams(lp); lcontent.addView(diseaselist); } else { View v = inflater.inflate(R.layout.fragment_disease, null); TextView listitem_name = (TextView) v.findViewById(R.id.listitem_name); TextView listitem_keshi = (TextView) v.findViewById(R.id.listitem_keshi); Button listitem_guahao = (Button) v.findViewById(R.id.listitem_guahao); TextView listitem_description = (TextView) v.findViewById(R.id.listitem_description); listitem_name.setText(data.getName()); listitem_keshi.setText(data.getKeshi()); listitem_description.setText(data.getDetaildata()); listitem_guahao.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(getActivity(), MainActivity.class); intent.putExtra("intent", "AppointmentFragment"); startActivity(intent); } }); lcontent.addView(v); } }