标签:
public class MyListView extends LinearLayout{ private LayoutInflater inflater; private ToggleButton toggle; private LinearLayout linear; public MyListView(Context context, AttributeSet attrs) { super(context, attrs); inflater = LayoutInflater.from(context); View view = inflater.inflate(R.layout.activity_price_item, this); linear = (LinearLayout) view.findViewById(R.id.price_relative); toggle = (ToggleButton) view.findViewById(R.id.price_item_toggle); toggle.setOnCheckedChangeListener(new OnCheckedChangeListener(){ @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if(isChecked){ linear.setVisibility(View.GONE); }else{ linear.setVisibility(View.VISIBLE); } } }); } }
<LinearLayout
android:id="@+id/price_image"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="5dp"
android:visibility="visible"
android:background="@drawable/back_border"
android:orientation="vertical">
</LinearLayout>
public class PriceItemAdapter extends BaseAdapter { private List<String> list; private Context context; private PriceViewHolder holder; private LayoutInflater inflater; public PriceItemAdapter(Context context,List<String> list) { this.context = context; this.list = list; } @Override public int getCount() { return list == null ? 0 :list.size(); } @Override public Object getItem(int position) { return list == null ? null : list.get(position); } @Override public long getItemId(int position) { return position; } @Override public View getView(int position, View convertView, ViewGroup parent) { if(convertView == null || convertView.getTag() == null){ holder = new PriceViewHolder(); inflater = LayoutInflater.from(context); //convertView = inflater.inflate(R.layout.activity_price_item, null); convertView = new MyListView(context, null); holder.tv_title = (TextView) convertView.findViewById(R.id.price_item_title); holder.tv_price = (TextView) convertView.findViewById(R.id.price_item_price); holder.et_text = (EditText) convertView.findViewById(R.id.price_item_reason); convertView.setTag(holder); }else{ holder = (PriceViewHolder) convertView.getTag(); } holder.tv_title.setText(list.get(position)); if(list != null){ holder.tv_title.setText(list.get(position)); } return convertView; } public class PriceViewHolder{ public TextView tv_title; public TextView tv_price; public ToggleButton toggleButton; public EditText et_text; private LinearLayout relative; } }
标签:
原文地址:http://www.cnblogs.com/dengshiwei/p/4493020.html