意见反馈Activity代码
This commit is contained in:
parent
d285e5e52f
commit
f1414c1ee0
|
@ -1,16 +1,32 @@
|
|||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/ll_root"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/white"
|
||||
android:orientation="vertical"
|
||||
tools:context=".Launcher" >
|
||||
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
<EditText
|
||||
android:id="@+id/et_message"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerInParent="true"
|
||||
android:src="@drawable/ic_launcher"
|
||||
android:contentDescription="@string/app_name"
|
||||
/>
|
||||
android:layout_margin="10dp"
|
||||
android:gravity="start"
|
||||
android:hint="@string/hint_feedback"
|
||||
android:inputType="textMultiLine"
|
||||
android:maxLength="1000"
|
||||
android:minLines="6" />
|
||||
|
||||
</RelativeLayout>
|
||||
<Button
|
||||
android:id="@+id/btn_sumbit"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="10dp"
|
||||
android:background="@color/blue"
|
||||
android:padding="10dp"
|
||||
android:text="@string/btn_submit"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="16sp" />
|
||||
|
||||
</LinearLayout>
|
|
@ -52,4 +52,8 @@
|
|||
<string name="btn_bind">绑定拦截</string>
|
||||
<!-- 短信操作示例(结束) -->
|
||||
|
||||
<string name="btn_submit">提交</string>
|
||||
<string name="hint_feedback">期待您的宝贵建议(1000字)</string>
|
||||
|
||||
|
||||
</resources>
|
||||
|
|
|
@ -1,18 +1,36 @@
|
|||
package com.zftlive.android.common;
|
||||
|
||||
import org.apache.http.Header;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
|
||||
import com.loopj.android.http.JsonHttpResponseHandler;
|
||||
import com.zftlive.android.R;
|
||||
import com.zftlive.android.base.BaseActivity;
|
||||
import com.zftlive.android.data.DTO;
|
||||
import com.zftlive.android.tools.ToolAlert;
|
||||
import com.zftlive.android.tools.ToolData;
|
||||
import com.zftlive.android.tools.ToolHTTP;
|
||||
import com.zftlive.android.tools.ToolString;
|
||||
|
||||
/**
|
||||
* 意见反馈Activity
|
||||
* @author Administrator
|
||||
* @version 1.0
|
||||
*/
|
||||
public class FeedbackActivity extends BaseActivity {
|
||||
public class FeedbackActivity extends BaseActivity implements OnClickListener {
|
||||
|
||||
private EditText et_message;
|
||||
private Button btn_sumbit;
|
||||
private ViewGroup root;
|
||||
private final static String FEED_BACK_URL = "";
|
||||
|
||||
@Override
|
||||
public int bindLayout() {
|
||||
return R.layout.activity_feedback;
|
||||
|
@ -20,7 +38,11 @@ public class FeedbackActivity extends BaseActivity {
|
|||
|
||||
@Override
|
||||
public void initView(View view) {
|
||||
|
||||
root = (ViewGroup)findViewById(R.id.ll_root);
|
||||
et_message = (EditText)findViewById(R.id.et_message);
|
||||
btn_sumbit = (Button)findViewById(R.id.btn_sumbit);
|
||||
//TODO 需真实数据接口
|
||||
// btn_sumbit.setOnClickListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -38,4 +60,50 @@ public class FeedbackActivity extends BaseActivity {
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
switch (v.getId()) {
|
||||
case R.id.btn_sumbit:
|
||||
//提交表单
|
||||
if(validateForm()){
|
||||
ToolHTTP.post(FEED_BACK_URL, ToolData.gainForm(root, new DTO<String,Object>()), getFeedBackHandler());
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 表单验证
|
||||
* @return
|
||||
*/
|
||||
private boolean validateForm(){
|
||||
String strMessage = et_message.getText().toString();
|
||||
if(ToolString.isNoBlankAndNoNull(strMessage)){
|
||||
return true;
|
||||
}else{
|
||||
ToolAlert.showShort(getContext(), "请输入意见内容再提交,谢谢^_^");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 提交意见反馈Handler
|
||||
*/
|
||||
private JsonHttpResponseHandler getFeedBackHandler(){
|
||||
return new JsonHttpResponseHandler(){
|
||||
|
||||
@Override
|
||||
public void onFailure(int statusCode, Header[] headers,String responseString, Throwable throwable) {
|
||||
ToolAlert.showShort(getContext(), "反馈意见失败,原因:"+throwable.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(int statusCode, Header[] headers,JSONObject response) {
|
||||
ToolAlert.showShort(getContext(), "感谢您的意见!");
|
||||
finish();
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue