-
dictionary
实现基于 android 中英互译电子词典代码 (android dictionral eng-ch)
- 2013-03-25 22:55:28下载
- 积分:1
-
Android tcp通讯学习用
核心代码:package com.Test;import android.os.Bundle;import android.os.Handler;import android.os.Message;import android.util.Log;import android.app.Activity;import android.view.Menu;import android.widget.Button;import android.view.View;import android.view.View.OnClickListener;import java.io.BufferedInputStream;import java.io.InputStream;import java.io.OutputStream;import java.io.IOException;import java.io.UnsupportedEncodingException;import java.io.InputStreamReader;import java.io.BufferedReader;import java.io.PrintWriter;import java.io.Reader;import java.net.Socket;import java.net.ServerSocket;import java.net.UnknownHostException;import android.view.TextureView;import android.widget.EditText;import java.lang.String;import java.lang.Thread;public class MainActivity extends Activity implements OnClickListener{ private Button m_btn; private Button m_sendbtn; private ServerSocket mySerSocket; private Socket clientSocket; private EditText m_edit; private String line; boolean conn = true; private Socket accSocket; private static final String Host = "10.0.2.2"; private static final int Port = 12000; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); m_btn = (Button)findViewById(R.id.button1); m_sendbtn = (Button)findViewById(R.id.button2); m_edit = (EditText)findViewById(R.id.editText1); //m_btn.setOnClickListener(this); m_btn.setOnClickListener(new ReceiverListener()); m_sendbtn.setOnClickListener(this); //Socket clientSocket = new Socket(Host, Port); } class ReceiverListener implements OnClickListener { private ReceiveThread mReceiveThread = null; private boolean stop = true; private Handler mHandler = null; public void onClick(View v) { try { if(clientSocket == null) { clientSocket = new Socket(Host, Port); } // InputStream myInputStream = clientSocket.getInputStream();// // //BufferedReader in = new BufferedReader(new InputStreamReader(myInputStream));//// byte [] buffer = new byte[myInputStream.available()]; //int temp = 0; //String strMsg = in.readLine(); // myInputStream.read(buffer);// // // String strMsg = new String(buffer);// // m_edit.setText(strMsg);// while ((temp = myInputStream.read(buffer)) != -1)// {// m_edit.setText(new String(buffer, 0, temp));//// } mReceiveThread = new ReceiveThread(clientSocket); stop = false; mReceiveThread.start(); } catch (IOException e) { e.printStackTrace(); } //消息处理 mHandler = new Handler() { public void handleMessage(Message msg) { m_edit.setText((msg.obj).toString()); } }; } private class ReceiveThread extends Thread { private InputStream inStream = null; private byte[] buf; private String str = null; ReceiveThread(Socket s) { try { this.inStream = s.getInputStream(); } catch(IOException e) { e.printStackTrace(); } } public void run() { while(!stop) { this.buf = new byte[512]; try { this.inStream.read(this.buf); } catch(IOException e) { e.printStackTrace(); } try { this.str = new String(this.buf, "GB2312").trim(); } catch(UnsupportedEncodingException e) { e.printStackTrace(); } Message msg = new Message(); msg.obj = this.str; mHandler.sendMessage(msg); } } } } public void onClick(View v) {// if (v.getId() == R.id.button1)// {// new Thread()// {// public void run()// {// try // {// if(clientSocket == null)// {// clientSocket = new Socket(Host, Port);// } // InputStream myInputStream = clientSocket.getInputStream();// // BufferedReader in = new BufferedReader(new InputStreamReader(myInputStream));//// byte [] buffer = new byte[1024 * 4];//// int temp = 0;// // String strMsg = in.readLine();// // //myInputStream.read(buffer);// // //String strMsg = new String(buffer);// // m_edit.setText(strMsg);////// while ((temp = myInputStream.read(buffer)) != -1)//// {//// m_edit.setText(new String(buffer, 0, temp));//////// }// // }// catch (IOException e)// {// e.printStackTrace();// }// }// }.start();// // } if(v.getId() == R.id.button2) { new Thread() { public void run() { try { if(clientSocket == null) { clientSocket = new Socket(Host, Port); } //inputStream clientInputStream = clientSocket. String msg = "RESET-SHOW"; //InputStream clientInputStream = clientSocket.getInputStream(); //BufferedReader br = new BufferedReader(new InputStreamReader(clientSocket.getInputStream())); //BufferedReader br = new BufferedReader(); //line = br.readLine(); OutputStream clientOutputStream = clientSocket.getOutputStream(); byte buffer[]=msg.getBytes(); clientOutputStream.write(buffer); clientOutputStream.flush(); //int temp = 0; // PrintWriter out = new PrintWriter(clientOutputStream);// // out.println("Serer Message: " msg); } catch(IOException e) { e.printStackTrace(); } } }.start(); } }private Reader InputStreamReader() { // TODO Auto-generated method stub return null; }// private Handler handler = new Handler()// {// public void handleMessage(Message msg)// {// super.handleMessage(msg);// //处理UI// m_edit.setText("Finish");// Log.i("PDA", "Finish");// // }// }; @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.main, menu); return true; }}
- 2014-08-18下载
- 积分:1
-
Android 游戏热
Android 游戏热,请发挥如果你喜欢这
基于您的源代码和说明的质量。质量低、 重复的代码或穷人所述将被删除。
- 2023-01-31 03:15:04下载
- 积分:1
-
协同过滤JAVA代码
用java写的协同过滤算法 基于item的协同过滤,通过用户对不同item的评分来评测item之间的相似性,基于item之间的相似性做出推荐;
- 2023-07-25 12:05:03下载
- 积分:1
-
这是非常好的项目
Lorem Ipsum 是印刷和排版行业的只是虚拟文本。Lorem Ipsum 一直以来在 1500 年,当未知的打印机类型厨房取炒,使标本书 industry 标准的虚拟文本。它经受住了五个世纪,也是跳入电子排版,基本保持不变。它被流行在 1960 年代与释放的 Letraset 表包含 Lorem Ipsum 通道,和更多最近与像 Aldus PageMaker 包括 Lorem Ipsum 版本的桌面出版软件。
- 2023-03-01 00:30:04下载
- 积分:1
-
js-beautify.php
Javascript beautifier for TextWrangler
- 2012-11-20 23:28:44下载
- 积分:1
-
jogl实现旋转立方体
使用opengl jogl实现的一个可以使用鼠标控制从各个方向查看的3D模型;实现非常简单
- 2022-05-18 02:19:41下载
- 积分:1
-
后台登录界面
资源描述Bootstrap后台登录界面模板基于Bootstrap3.0.3+CSS3制作,界面简洁,响应式设计,自适应屏幕分辨率,兼容PC端和手机移动端,带简单表单验证功能。
- 2022-11-16 13:00:06下载
- 积分:1
-
java小游戏HangmanCL
java的小游戏程序,游戏会给出一系列的缺少部分字母的单词,并且会给出提示,让玩家去添词中缺少的字母,每个玩家猜错一次将会在吊死鬼的图像中画上一笔,当猜错次数足够完成吊死鬼的图片时,游戏结束
- 2022-07-01 15:10:12下载
- 积分:1
-
TQEditor.2.3.6
TQEditor.2.3.6最经典的在线编辑word文档源代码,实现公文收发管理合同签约在线编辑word文档,如果有需要可以直接代替网页版的word文档实现你的网页快速开发,希望有需要的朋友可以下载使用,是一款经典的集成word的文档控件……
- 2022-04-23 19:36:42下载
- 积分:1