/******************MyLinearLayout.java/
public class MyLinearLayout extends LinearLayout {
TextView ordinal,delete;
View view;
public MyLinearLayout(Context context, final int num) {
super(context);
LayoutInflater.from(context).inflate(R.layout.club_vote_item,this);
ordinal=findViewById(R.id.vote_ordinal);
String str=""+num;
ordinal.setText(str);
delete=findViewById(R.id.delete);
delete.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(getContext(),"click"+num+"",Toast.LENGTH_SHORT).show();
// removeView(view);
}
});
}
}
/*******************MyLinearLayout.java/
/******************vote_activity.xml/
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
tools:layout_editor_absoluteY="81dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:focusable="true"
android:focusableInTouchMode="true">
<EditText
android:id="@+id/postTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:background="@color/colorTitle"
android:hint="输入帖子标题"
android:padding="8dp"
android:textSize="22dp" />
<EditText
android:id="@+id/postText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/postTitle"
android:layout_weight="1"
android:background="@color/colorWhite"
android:gravity="left"
android:hint="输入正文内容……"
android:minLines="8"
android:padding="8dp"
android:textSize="22dp" />
<TextView
android:id="@+id/line1"
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_below="@id/postText"
android:background="@color/colorTitle" />
<RadioGroup
android:id="@+id/vote_type_group"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/line1"
android:orientation="horizontal">
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:text="单选投票" />
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:text="多选投票" />
</RadioGroup>
<TextView
android:id="@+id/line2"
android:layout_width="match_parent"
android:layout_height="0.5dp"
android:layout_below="@id/vote_type_group"
android:background="@color/colorTitle" />
<RelativeLayout
android:id="@+id/datebar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/line2">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_margin="10dp"
android:text="投票截止日期" />
<TextView
android:id="@+id/datetext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_margin="10dp"
android:hint="xxxx-xx-xx" />
<ImageView
android:id="@+id/datepick"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_marginTop="0dp"
android:src="@mipmap/ic_launcher" />
</RelativeLayout>
<ScrollView
android:layout_marginBottom="65dp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/datebar">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:id="@+id/vote_item"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout
android:id="@+id/vote_t"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_margin="12dp">
<TextView
android:id="@+id/vote_ordinal"
android:layout_width="50dp"
android:layout_height="match_parent"
android:layout_alignParentStart="true"
android:background="@color/colorVotetips"
android:gravity="center"
android:text="1" />
<EditText
android:id="@+id/vote_tipedit"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_toRightOf="@id/vote_ordinal"
android:background="@color/colorVote" />
<TextView
android:id="@+id/delete"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_alignParentRight="true"
android:background="@color/colorTitle"
android:gravity="center"
android:text="X" />
</RelativeLayout>
</LinearLayout>
<TextView
android:id="@+id/addvote"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_margin="5dp"
android:gravity="center"
android:padding="5dp"
android:text="+添加投票选项" />
</LinearLayout>
</ScrollView>
<RelativeLayout
android:visibility="gone"
android:id="@+id/footbar"
android:layout_width="match_parent"
android:layout_height="65dp"
android:layout_alignParentBottom="true"
android:background="@color/colorTitle"></RelativeLayout>
</RelativeLayout>
</android.support.constraint.ConstraintLayout>
/*****************vote_activity.xml/
/**************vote_item.xml/
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_margin="12dp">
<TextView
android:id="@+id/vote_ordinal"
android:layout_width="50dp"
android:layout_height="match_parent"
android:layout_alignParentStart="true"
android:background="@color/colorVotetips"
android:gravity="center"
android:text="1" />
<EditText
android:id="@+id/vote_tipedit"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_toRightOf="@id/vote_ordinal"
android:background="@color/colorVote" />
<TextView
android:id="@+id/delete"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_alignParentRight="true"
android:background="@color/colorTitle"
android:gravity="center"
android:text="X" />
</RelativeLayout>
/****************vote_item.xml/
/***************custom_date_picker.xml/
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorWhite"
android:paddingLeft="10dp"
android:paddingTop="5dp"
android:paddingRight="10dp"
android:paddingBottom="5dp">
<TextView
android:id="@+id/tv_cancle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:padding="10dp"
android:text="取消"
android:textColor="@color/color_bg"
android:textSize="16sp" />
<TextView
android:id="@+id/tv_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="@string/title"
android:textColor="@color/color_bg"
android:textSize="20sp" />
<TextView
android:id="@+id/tv_select"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:padding="10dp"
android:text="@string/commit"
android:textColor="@color/color_bg"
android:textSize="16sp" />
</RelativeLayout>
<View
android:layout_width="match_parent"
android:layout_height="0.5dp" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/color_bg">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:background="@color/colorWhite"
android:orientation="horizontal"
android:paddingLeft="20dp"
android:paddingTop="15dp"
android:paddingRight="20dp"
android:paddingBottom="15dp">
<com.example.hasee.myapplication.datepicker.DatePickerView
android:id="@+id/year_pv"
android:layout_width="0dp"
android:layout_height="160dp"
android:layout_weight="3" />
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:text="@string/year"
android:textColor="@color/color_bg"
android:textSize="18sp" />
<com.example.hasee.myapplication.datepicker.DatePickerView
android:id="@+id/month_pv"
android:layout_width="0dp"
android:layout_height="160dp"
android:layout_weight="2" />
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:text="@string/month"
android:textColor="@color/color_bg"
android:textSize="18sp" />
<com.example.hasee.myapplication.datepicker.DatePickerView
android:id="@+id/day_pv"
android:layout_width="0dp"
android:layout_height="160dp"
android:layout_weight="2" />
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:text="@string/day"
android:textColor="@color/color_bg"
android:textSize="18sp" />
<com.example.hasee.myapplication.datepicker.DatePickerView
android:id="@+id/hour_pv"
android:layout_width="0dp"
android:layout_height="160dp"
android:layout_weight="2" />
<TextView
android:id="@+id/hour_text"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:text="@string/hour"
android:textColor="@color/color_bg"
android:textSize="18sp" />
<com.example.hasee.myapplication.datepicker.DatePickerView
android:id="@+id/minute_pv"
android:layout_width="0dp"
android:layout_height="160dp"
android:layout_weight="2" />
<TextView
android:id="@+id/minute_text"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:text="@string/minute"
android:textColor="@color/color_bg"
android:textSize="18sp" />
</LinearLayout>
</RelativeLayout>
</LinearLayout>
/***************custom_date_picker.xml/
/***************strings.xml/
<resources>
<string name="app_name">My Application</string>
<string name="cancle">取消</string>
<string name="title">请选择时间</string>
<string name="commit">确定</string>
<string name="year">年</string>
<string name="month">月</string>
<string name="day">日</string>
<string name="hour">时</string>
<string name="minute">分</string>
<string name="select_date">选择日期</string>
<string name="current_date">当前日期</string>
<string name="select_time">选择时间</string>
<string name="current_time">当前时间</string>
</resources>
/**************strings.xml/
/**************style.xml/
<style name="TimePickerDialog" parent="android:style/Theme.Dialog">
<item name="android:windowFrame">@null</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowIsFloating">true</item>
<item name="android:windowContentOverlay">@null</item>
<!--<item name="android:windowBackground">@color/color_bg</item>-->
</style>
/**************style.xml/