标签:down 三级联动 pat instance src 技术分享 span over click
最近项目要做一个电商APP,选择收货地址的三级联动滚动选择组件, 控件用起来非常简单 ,下面是它的运行效果:
布局
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" xmlns:su="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity" android:orientation="vertical" > <TextView android:id="@+id/tv_name" android:layout_width="match_parent" android:layout_height="56dp" android:gravity="center" android:textColor="#FF0000" android:textSize="22sp" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="选择地址" /> <com.city.linkage.CityPickerView android:id="@+id/citypicker" android:layout_width="fill_parent" android:layout_height="156dp" android:layout_gravity="center" android:gravity="center"></com.city.linkage.CityPickerView> <Button android:id="@+id/btn" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="确定" /> </LinearLayout>
MainActivity.Java
public class MainActivity extends AppCompatActivity { private CityPickerView cityPicker; private TextView tv; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); cityPicker = (CityPickerView) findViewById(R.id.citypicker); tv=(TextView)findViewById(R.id.tv_name); findViewById(R.id.btn).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { tv.setText(cityPicker.getCity_string()); } }); } }
标签:down 三级联动 pat instance src 技术分享 span over click
原文地址:http://www.cnblogs.com/zhangqie/p/6432155.html