友盟意见反馈——对话框改为单一的用户反馈

前端之家收集整理的这篇文章主要介绍了友盟意见反馈——对话框改为单一的用户反馈前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。


友盟意见反馈——对话框改为单一的用户反馈


1.实现的效果:由自带的左图对话框的样式变为右图单一的反馈形式,并把用户信息放到同一个界面


2.布局文件

把umeng_fb_activity_contact.xml和umeng_fb_activity_conversation.xml合二为一,如下:

[java] view plain copy
  1. <RelativeLayoutxmlns:android="http://schemas.android.com/apk/res/android"
  2. xmlns:tools="http://schemas.android.com/tools"
  3. android:layout_width="fill_parent"
  4. android:layout_height="fill_parent"
  5. android:background="#ffffff"
  6. android:orientation="vertical"
  7. tools:context=".ConversationActivity">
  8. <EditText
  9. android:id="@+id/umeng_fb_replyContent"
  10. android:layout_width="match_parent"
  11. android:layout_height="150dp"
  12. android:layout_marginLeft="15dp"
  13. android:layout_marginRight="15dp"
  14. android:layout_marginTop="15dp"
  15. android:background="@drawable/Feedback_bg"
  16. android:gravity="top"
  17. android:hint="@string/umeng_fb_reply_content_hint"
  18. android:paddingBottom="10dp"
  19. android:paddingLeft="15dp"
  20. android:paddingRight="10dp"
  21. android:paddingTop="10dp"
  22. android:textColorHint="#dbdbdb"
  23. android:textSize="15sp">
  24. <requestFocus/>
  25. </EditText>
  26. <TextView
  27. android:id="@+id/textView1"
  28. android:layout_width="wrap_content"
  29. android:layout_height="26dp"
  30. android:layout_alignLeft="@+id/umeng_fb_replyContent"
  31. android:layout_below="@+id/umeng_fb_replyContent"
  32. android:layout_marginTop="10dp"
  33. android:text="@string/umeng_fb_contact_info"
  34. android:textColorHighlight="#797979"
  35. android:textSize="15sp"/>
  36. <EditText
  37. android:id="@+id/umeng_fb_contactInfo"
  38. android:layout_width="fill_parent"
  39. android:layout_height="50dp"
  40. android:layout_alignLeft="@+id/textView1"
  41. android:layout_alignRight="@+id/umeng_fb_replyContent"
  42. android:layout_below="@+id/textView1"
  43. android:layout_marginTop="5dp"
  44. android:background="@drawable/ic_more_item_default"
  45. android:focusable="true"
  46. android:focusableInTouchMode="true"
  47. android:hint="@string/umeng_fb_contact_info_hint"
  48. android:paddingBottom="10dp"
  49. android:paddingLeft="15dp"
  50. android:paddingRight="10dp"
  51. android:paddingTop="10dp"
  52. android:textColorHint="#dbdbdb"
  53. android:textSize="15sp">
  54. </EditText>
  55. </RelativeLayout>

3.主要代码

把友盟官方提供的ConversationActivity和ContactActivity合二为一,如下:

copy
    publicclassConversationActivityextendsSherlockActivity{
  1. //privatestaticfinalStringTAG=ConversationActivity.class.getName();
  2. privatestaticfinalStringKEY_UMENG_CONTACT_INFO_PLAIN_TEXT="plain";
  3. privateFeedbackAgentagent;
  4. privateConversationdefaultConversation;
  5. EditTextuserReplyContentEdit,contactInfo;
  6. ButtonsendBtn;
  7. ImageButtonbackBtn;
  8. privateTextViewtv_title;
  9. privateRadioButtonback_imbt;
  10. privateTextWatcherwatcher=newTextWatcher(){
  11. @Override
  12. voidonTextChanged(CharSequences,intstart,153); background-color:inherit; font-weight:bold">intbefore,
  13. intcount){
  14. }
  15. @Override
  16. voidbeforeTextChanged(CharSequences,153); background-color:inherit; font-weight:bold">intcount,
  17. intafter){
  18. }
  19. voidafterTextChanged(Editables){
  20. sendBtn.setClickable(true);
  21. sendBtn.setBackgroundColor(Color.parseColor("#ff0000"));
  22. sendBtn.setOnClickListener(newOnClickListener(){
  23. voidonClick(Viewv){
  24. Stringcontent=userReplyContentEdit.getEditableText()
  25. .toString().trim();
  26. if(TextUtils.isEmpty(content))
  27. return;
  28. if(content.length()<10)
  29. return;
  30. Toast.makeText(ConversationActivity.this,108); list-style:decimal-leading-zero outside; color:inherit; line-height:20px; margin:0px!important; padding:0px 3px 0px 10px!important"> "Thanksforyouradvice.",Toast.LENGTH_SHORT)
  31. .show();
  32. userReplyContentEdit.getEditableText().clear();
  33. defaultConversation.addUserReply(content);
  34. sync();
  35. InputMethodManagerimm=(InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
  36. if(imm!=null)
  37. imm.hideSoftInputFromWindow(
  38. userReplyContentEdit.getWindowToken(),0);
  39. UserInfoinfo=agent.getUserInfo();
  40. if(info==null)
  41. info=newUserInfo();
  42. Map<String,String>contact=info.getContact();
  43. if(contact== contact=newHashMap<String,String>();
  44. Stringcontact_info=contactInfo.getEditableText()
  45. .toString();
  46. contact.put(KEY_UMENG_CONTACT_INFO_PLAIN_TEXT,contact_info);
  47. info.setContact(contact);
  48. agent.setUserInfo(info);
  49. contactInfo.getEditableText().clear();
  50. });
  51. };
  52. protectedvoidonCreate(BundlesavedInstanceState){
  53. super.onCreate(savedInstanceState);
  54. setContentView(R.layout.umeng_fb_activity_conversation);
  55. try{
  56. agent=newFeedbackAgent(this);
  57. defaultConversation=agent.getDefaultConversation();
  58. sync();
  59. userReplyContentEdit=(EditText)findViewById(R.id.umeng_fb_replyContent);
  60. contactInfo=(EditText)findViewById(R.id.umeng_fb_contactInfo);
  61. userReplyContentEdit.addTextChangedListener(watcher);
  62. }catch(Exceptione){
  63. e.printStackTrace();
  64. this.finish();
  65. voidonStart(){
  66. super.onStart();
  67. getSupportActionBar().setDisplayHomeAsUpEnabled(false);
  68. getSupportActionBar().setDisplayShowHomeEnabled(false);
  69. getSupportActionBar().setDisplayShowTitleEnabled( getSupportActionBar().setBackgroundDrawable(
  70. getResources().getDrawable(R.drawable.top1));
  71. initActionBar();
  72. voidinitActionBar(){
  73. getSupportActionBar().setDisplayShowCustomEnabled( ViewactionbarLayout=LayoutInflater.from(this).inflate(
  74. R.layout.jyx_actionbar_edit,null);
  75. getSupportActionBar().setCustomView(actionbarLayout);
  76. back_imbt=(RadioButton)actionbarLayout.findViewById(R.id.back_imbt);
  77. sendBtn=(Button)actionbarLayout.findViewById(R.id.edit_imbt);
  78. tv_title=(TextView)actionbarLayout.findViewById(R.id.tv_title);
  79. tv_title.setText("Advice");
  80. sendBtn.setText("Send");
  81. sendBtn.setClickable( back_imbt.setOnClickListener(voidonClick(Viewview){
  82. finish();
  83. });
  84. voidsync(){
  85. Conversation.SyncListenerlistener=newConversation.SyncListener(){
  86. voidonSendUserReply(List<Reply>replyList){
  87. voidonReceiveDevReply(List<DevReply>replyList){
  88. defaultConversation.sync(listener);
  89. }
原文链接:https://www.f2er.com/javaschema/284796.html

猜你在找的设计模式相关文章