首先在PC服务端 ipconfig,获取 IPv4地址:1921.68.1.103。端口号随便写,大于 1024 即可。

【注】不能再主线程里 new Socket(),否则可能真机不能运行,模拟机可以。

1、Android 端 Layout 布局文件。

 1 <RelativeLayout xmlns:andro
 2     xmlns:tools="http://schemas.android.com/tools"
 3     android:layout_width="match_parent"
 4     android:layout_height="match_parent"
 5     android:paddingBottom="@dimen/activity_vertical_margin"
 6     android:paddingLeft="@dimen/activity_horizontal_margin"
 7     android:paddingRight="@dimen/activity_horizontal_margin"
 8     android:paddingTop="@dimen/activity_vertical_margin"
 9     tools:context=".MainActivity" >
10     
11     <LinearLayout
12         android:layout_width="fill_parent"
13         android:layout_height="wrap_content"
14         android:
15         android:gravity="bottom"
16         android:orientation="horizontal" >
17 
18         <EditText 
19             android:layout_width="match_parent"
20             android:layout_height="wrap_content"
21             android:maxLines="1"
22             android:layout_weight="1.0"
23             android:
24             />
25         <Button 
26             android:layout_width="wrap_content"
27             android:layout_height="wrap_content"
28             android:
29             android:text="发送"
30             />
31     </LinearLayout>
32 
33     <ScrollView
34         android:
35         android:layout_width="fill_parent"
36         android:layout_height="match_parent"
37         android:layout_below="@id/layout1"
38         android:background="#cccccc"
39         android:scrollbars="vertical|none" >
40 
41         <TextView
42             android:
43             android:layout_width="fill_parent"
44             android:layout_height="wrap_content" />
45 
46     </ScrollView>
47 </RelativeLayout>
activity_main.xml

相关文章:

  • 2021-07-10
  • 2021-11-15
  • 2021-12-09
  • 2021-11-05
  • 2021-06-11
  • 2022-01-14
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-11-29
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案