Umeng feedback-change the dialog box to a single user feedback
1. Effects: the style of the left-side dialog box is changed to a single feedback form for the right-side image, and the user information is placed on the same interface.
2. layout file: <喎?http: www.bkjia.com kf ware vc " target="_blank" class="keylink"> VcD4KPHA + fuse/Co7o8L3A + CjxwPjxwcmUgY2xhc3M9 "brush: java;">
3. Main Code:
Combine ConversationActivity and ContactActivity officially provided by umeng, as follows:
public class ConversationActivity extends SherlockActivity {// private static final String TAG = ConversationActivity.class.getName();private static final String KEY_UMENG_CONTACT_INFO_PLAIN_TEXT = "plain";private FeedbackAgent agent;private Conversation defaultConversation;EditText userReplyContentEdit, contactInfo;Button sendBtn;ImageButton backBtn;private TextView tv_title;private RadioButton back_imbt;private TextWatcher watcher = new TextWatcher() {@Overridepublic void onTextChanged(CharSequence s, int start, int before,int count) {}@Overridepublic void beforeTextChanged(CharSequence s, int start, int count,int after) {}@Overridepublic void afterTextChanged(Editable s) {sendBtn.setClickable(true);sendBtn.setBackgroundColor(Color.parseColor("#ff0000"));sendBtn.setOnClickListener(new OnClickListener() {@Overridepublic void onClick(View v) {String content = userReplyContentEdit.getEditableText().toString().trim();if (TextUtils.isEmpty(content))return;if (content.length() < 10)return;Toast.makeText(ConversationActivity.this,"Thanks for your advice.", Toast.LENGTH_SHORT).show();userReplyContentEdit.getEditableText().clear();defaultConversation.addUserReply(content);sync();InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);if (imm != null)imm.hideSoftInputFromWindow(userReplyContentEdit.getWindowToken(), 0);UserInfo info = agent.getUserInfo();if (info == null)info = new UserInfo();Map
contact = info.getContact();if (contact == null)contact = new HashMap
();String contact_info = contactInfo.getEditableText().toString();contact.put(KEY_UMENG_CONTACT_INFO_PLAIN_TEXT, contact_info);info.setContact(contact);agent.setUserInfo(info);contactInfo.getEditableText().clear();}});}};@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.umeng_fb_activity_conversation);try {agent = new FeedbackAgent(this);defaultConversation = agent.getDefaultConversation();sync();userReplyContentEdit = (EditText) findViewById(R.id.umeng_fb_replyContent);contactInfo = (EditText) findViewById(R.id.umeng_fb_contactInfo);userReplyContentEdit.addTextChangedListener(watcher);} catch (Exception e) {e.printStackTrace();this.finish();}}@Overrideprotected void onStart() {super.onStart();getSupportActionBar().setDisplayHomeAsUpEnabled(false);getSupportActionBar().setDisplayShowHomeEnabled(false);getSupportActionBar().setDisplayShowTitleEnabled(false);getSupportActionBar().setBackgroundDrawable(getResources().getDrawable(R.drawable.top1));initActionBar();}private void initActionBar() {getSupportActionBar().setDisplayShowCustomEnabled(true);View actionbarLayout = LayoutInflater.from(this).inflate(R.layout.jyx_actionbar_edit, null);getSupportActionBar().setCustomView(actionbarLayout);back_imbt = (RadioButton) actionbarLayout.findViewById(R.id.back_imbt);sendBtn = (Button) actionbarLayout.findViewById(R.id.edit_imbt);tv_title = (TextView) actionbarLayout.findViewById(R.id.tv_title);tv_title.setText("Advice");sendBtn.setText("Send");sendBtn.setClickable(false);back_imbt.setOnClickListener(new OnClickListener() {@Overridepublic void onClick(View view) {finish();}});}void sync() {Conversation.SyncListener listener = new Conversation.SyncListener() {@Overridepublic void onSendUserReply(List
replyList) {}@Overridepublic void onReceiveDevReply(List
replyList) {}};defaultConversation.sync(listener);}}