-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b7527dd
commit 27a01a9
Showing
7 changed files
with
187 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package com.telchina.wx; | ||
|
||
/** | ||
* Created by zg on 2015/8/9. | ||
*/ | ||
public class Msg { | ||
|
||
public static final int TYPE_RECEIVED = 0; | ||
public static final int TYPE_SEND = 1; | ||
|
||
private String content; | ||
private int type; | ||
|
||
public Msg(String content, int type) { | ||
this.content = content; | ||
this.type = type; | ||
} | ||
|
||
public String getContent() { | ||
return content; | ||
} | ||
|
||
public void setContent(String content) { | ||
this.content = content; | ||
} | ||
|
||
public int getType() { | ||
return type; | ||
} | ||
|
||
public void setType(int type) { | ||
this.type = type; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package com.telchina.wx; | ||
|
||
import android.content.Context; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.widget.ArrayAdapter; | ||
import android.widget.LinearLayout; | ||
import android.widget.TextView; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* Created by zg on 2015/8/9. | ||
*/ | ||
public class MsgAdapter extends ArrayAdapter<Msg> { | ||
|
||
private int resourceId; | ||
|
||
public MsgAdapter(Context context, int textViewResourceId, List<Msg> objects) { | ||
super(context, textViewResourceId, objects); | ||
resourceId = textViewResourceId; | ||
} | ||
|
||
@Override | ||
public View getView(int position, View convertView, ViewGroup parent) { | ||
Msg msg = getItem(position); | ||
View view; | ||
ViewHolder viewHolder; | ||
|
||
if (convertView == null) { | ||
view = LayoutInflater.from(getContext()).inflate(resourceId, null); | ||
viewHolder = new ViewHolder(); | ||
viewHolder.leftLayout = (LinearLayout) view.findViewById(R.id.left_layout); | ||
viewHolder.rightLayout = (LinearLayout) view.findViewById(R.id.right_layout); | ||
viewHolder.leftMsg = (TextView) view.findViewById(R.id.left_msg); | ||
viewHolder.rightMsg = (TextView) view.findViewById(R.id.right_msg); | ||
view.setTag(viewHolder); | ||
} else { | ||
view = convertView; | ||
viewHolder = (ViewHolder) view.getTag(); | ||
} | ||
|
||
if (msg.getType() == Msg.TYPE_RECEIVED) { | ||
viewHolder.leftLayout.setVisibility(View.VISIBLE); | ||
viewHolder.rightLayout.setVisibility(View.GONE); | ||
viewHolder.leftMsg.setText(msg.getContent()); | ||
|
||
} else if (msg.getType() == Msg.TYPE_SEND) { | ||
viewHolder.rightLayout.setVisibility(View.VISIBLE); | ||
viewHolder.leftLayout.setVisibility(View.GONE); | ||
viewHolder.rightMsg.setText(msg.getContent()); | ||
} | ||
|
||
return view; | ||
} | ||
|
||
private class ViewHolder { | ||
|
||
LinearLayout leftLayout; | ||
LinearLayout rightLayout; | ||
|
||
TextView leftMsg; | ||
TextView rightMsg; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.telchina.wx; | ||
|
||
/** | ||
* Created by zg on 2015/8/9. | ||
*/ | ||
public class News { | ||
|
||
|
||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?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="match_parent" | ||
android:orientation="vertical" | ||
android:padding="10dp"> | ||
|
||
<LinearLayout | ||
android:id="@+id/left_layout" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_gravity="left" | ||
android:background="@drawable/message_left"> | ||
|
||
<TextView | ||
android:id="@+id/left_msg" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_margin="10dp" | ||
android:gravity="center" | ||
android:textColor="#fff" /> | ||
|
||
</LinearLayout> | ||
|
||
<LinearLayout | ||
android:id="@+id/right_layout" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_gravity="right" | ||
android:background="@drawable/message_right"> | ||
|
||
<TextView | ||
android:id="@+id/right_msg" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_margin="10dp" | ||
android:gravity="center" | ||
android:textColor="#fff" /> | ||
|
||
</LinearLayout> | ||
|
||
</LinearLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:orientation="vertical" | ||
android:background="#D8E0E8" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent"> | ||
|
||
<ListView | ||
android:id="@+id/msg_list_view" | ||
android:layout_width="match_parent" | ||
android:layout_height="0dp" | ||
android:layout_weight="1" | ||
android:divider="#0000"/> | ||
|
||
<LinearLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content"> | ||
|
||
<EditText | ||
android:id="@+id/input_edit_text" | ||
android:layout_width="0dp" | ||
android:layout_height="wrap_content" | ||
android:layout_weight="1" | ||
android:hint="@string/edit_hint_text" | ||
android:maxLines="2"/> | ||
|
||
<Button | ||
android:id="@+id/send_button" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:text="@string/send_btn_text"/> | ||
|
||
</LinearLayout> | ||
|
||
|
||
</LinearLayout> |