- 浏览: 154116 次
- 性别:
- 来自: 杭州
文章分类
最新评论
-
liveandevil:
我的一直出现驱动找不到的错误 你那个驱动jar文件时放在哪里 ...
JDBC数据库通用DAO -
zouc816:
hi,wjm901215
我看你这篇文章对mapXtreme ...
用mapXtreme Java开发web gis应用 (下)
1、LoginWindow.java --登录窗口 view plaincopy to clipboardprint? package com.hemi.rhet; import com.hemi.rhet.R; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.KeyEvent; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.CheckBox; import android.widget.EditText; public class LoginWindow extends Activity { @Override public void onCreate(Bundle savedInstanceState) { System.out.println("enter LoginWindow.onCreate()!"); super.onCreate(savedInstanceState); setContentView(R.layout.login_window); mUserName = (EditText)findViewById(R.id.username); mUserPasswd = (EditText)findViewById(R.id.userpasswd); cbx_cmwap = (CheckBox) findViewById(R.id.cbx_cmwap); loginButton = (Button) findViewById(R.id.login_button); exitButton = (Button) findViewById(R.id.exit_button); loginBtnListener = new View.OnClickListener() { public void onClick(View view) { LoginWindow.isCmwap = cbx_cmwap.isChecked(); if (view == loginButton) { launchFetion(); } else if(view == exitButton) { finish(); } } }; loginButton.setOnClickListener(loginBtnListener); exitButton.setOnClickListener(loginBtnListener); } private void launchFetion() { Intent i = new Intent(this, FuncSelector.class); i.putExtra(KEY_LOGIN_NAME, mUserName.getText().toString()); i.putExtra(KEY_LOGIN_PASSWD, mUserPasswd.getText().toString()); i.putExtra(KEY_LOGIN_TYPE, cbx_cmwap.isChecked()); startActivity(i); } @Override public boolean onKeyDown(int keyCode, KeyEvent msg) { // System.out.println("enter onKeyDown() in LoginWindow!"); // // if (null != loginBtnListener) { // View aview = getCurrentFocus(); // loginBtnListener.onClick(aview); // } return false; } private Button loginButton, exitButton; private EditText mUserName; private EditText mUserPasswd; private CheckBox cbx_cmwap; private OnClickListener loginBtnListener; public static final String KEY_LOGIN_NAME = "login_name"; public static final String KEY_LOGIN_PASSWD = "login_passwd"; public static final String KEY_LOGIN_TYPE = "login_type"; public static boolean isCmwap = false; } 2. FuncSelector.java -- 功能模块选择窗口 view plaincopy to clipboardprint? package com.hemi.rhet; import java.util.ArrayList; import java.util.HashMap; import com.hemi.rhet.R; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.util.Log; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.widget.AdapterView; import android.widget.GridView; import android.widget.SimpleAdapter; import android.widget.AdapterView.OnItemClickListener; public class FuncSelector extends Activity { @Override public void onCreate(Bundle savedInstanceState) { Log.i("info", "enter LoginWindow.onCreate()!"); super.onCreate(savedInstanceState); setContentView(R.layout.func_selector); initFuncGrids(); } private void initFuncGrids() { GridView funcSeleView = (GridView) findViewById(R.id.func_selector); // 生成动态数组,并且转入数据 ArrayList<HashMap<String, Object>> lstImageItem = new ArrayList<HashMap<String, Object>>(); HashMap<String, Object> map = new HashMap<String, Object>(); map.put("ItemImage", R.drawable.photo_upload); // 添加图像资源的ID map.put("ItemText", getString(R.string.photo_upload)); // 按序号做ItemText lstImageItem.add(map); map = new HashMap<String, Object>(); map.put("ItemImage", R.drawable.icon); map.put("ItemText", getString(R.string.sys_config)); lstImageItem.add(map); for (int i = 1; i <= 10; i++) { map = new HashMap<String, Object>(); map.put("ItemImage", R.drawable.icon); // 添加图像资源的ID map.put("ItemText", "NO." + String.valueOf(i)); // 按序号做ItemText lstImageItem.add(map); } // 生成适配器的ImageItem <====> 动态数组的元素,两者一一对应 SimpleAdapter saImageItems = new SimpleAdapter(this, // 没什么解释 lstImageItem,// 数据来源 R.layout.night_item,// night_item的XML实现 // 动态数组与ImageItem对应的子项 new String[] { "ItemImage", "ItemText" }, // ImageItem的XML文件里面的一个ImageView,两个TextView ID new int[] {R.id.ItemImage,R.id.ItemText}); //null); // 添加并且显示 funcSeleView.setAdapter(saImageItems); //saImageItems.notifyDataSetChanged(); // 添加消息处理 funcSeleView.setOnItemClickListener(new ItemClickListener()); } public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); menu.add(0, EXIT_ID,0, R.string.back_button); return true; } //@Override public boolean onMenuItemSelected(int featureId, MenuItem item) { boolean result = true; switch(item.getItemId()) { case EXIT_ID: this.finish(); break; default: result = super.onMenuItemSelected(featureId, item); break; } return result; } // 当AdapterView被单击(触摸屏或者键盘),则返回的Item单击事件 class ItemClickListener implements OnItemClickListener { public void onItemClick(AdapterView<?> arg0,// The AdapterView where the // click happened View arg1,// The view within the AdapterView that was clicked int arg2,// The position of the view in the adapter long arg3// The row id of the item that was clicked ) { // 在本例中arg2=arg3 HashMap<String, Object> item = (HashMap<String, Object>) arg0 .getItemAtPosition(arg2); String tmpStr = (String) item.get("ItemText"); //item.put("ItemText", tmpStr + tmpStr.substring(tmpStr.length() - 1)); // 显示所选Item的ItemText // setTitle((String)item.get("ItemText")); Log.i("info", (String) item.get("ItemText")); ((SimpleAdapter) arg0.getAdapter()).notifyDataSetChanged(); Intent i; switch (arg2) { case 0: i = new Intent(); i.setClass(FuncSelector.this, PhotoUpload.class); startActivity(i); break; case 1: i = new Intent(); i.setClass(FuncSelector.this, ConfigWindow.class); startActivity(i); break; default: break; } } } private static final int TAKE_PHOTO_ID = Menu.FIRST; private static final int UPLOAD_PHOTO_ID = Menu.FIRST + 1; private static final int EXIT_ID = Menu.FIRST + 3; }//FuncSelector 3. PhotoUpload.java -- 照片上传模块 view plaincopy to clipboardprint? package com.hemi.rhet; import java.io.BufferedReader; import java.io.ByteArrayOutputStream; import java.io.DataOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.UnsupportedEncodingException; import java.net.HttpURLConnection; import java.net.MalformedURLException; import java.net.URL; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; import java.util.HashMap; import java.util.List; import org.apache.http.Header; import org.apache.http.HttpResponse; import org.apache.http.NameValuePair; import org.apache.http.client.ClientProtocolException; import org.apache.http.client.HttpClient; import org.apache.http.client.entity.UrlEncodedFormEntity; import org.apache.http.client.methods.HttpPost; import org.apache.http.entity.FileEntity; import org.apache.http.impl.client.DefaultHttpClient; import org.apache.http.message.BasicNameValuePair; import com.hemi.rhet.R; import android.app.Activity; import android.content.Intent; import android.graphics.Bitmap; import android.net.Uri; import android.os.Bundle; import android.os.Environment; import android.util.Log; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.widget.AdapterView; import android.widget.GridView; import android.widget.ImageView; import android.widget.SimpleAdapter; import android.widget.Toast; import android.widget.AdapterView.OnItemClickListener; public class PhotoUpload extends Activity { @Override public void onCreate(Bundle savedInstanceState) { Log.i("info", "enter LoginWindow.onCreate()!"); super.onCreate(savedInstanceState); setContentView(R.layout.func_selector); } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (TAKE_PHOTO_ID == requestCode) { if (resultCode != RESULT_OK) return; Bundle extras = data.getExtras(); try { Bitmap photoCaptured = (Bitmap) extras.get("data"); ImageView img = new ImageView(this); img.setImageBitmap(photoCaptured); setContentView(img); //store to sd card ByteArrayOutputStream baos = new ByteArrayOutputStream(); photoCaptured.compress(Bitmap.CompressFormat.JPEG, 100, baos); byte[] photoBytes = baos.toByteArray(); File aFile = new File(getDatedFName(SD_CARD_TEMP_DIR)); photoPath = aFile.getAbsolutePath(); boolean b; if (aFile.exists()) b = aFile.delete(); //f.mkdirs(); aFile.createNewFile(); //need add permission to manifest FileOutputStream fos = new FileOutputStream(aFile); fos.write(photoBytes); fos.close(); Log.d("info", "onPictureTaken - wrote bytes: " + photoBytes.length); Uri capturedImage = Uri .parse(android.provider.MediaStore.Images.Media .insertImage(getContentResolver(), aFile .getAbsolutePath(), null, null)); Log.i("camera", "Selected image: " + capturedImage.toString()); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } else if (UPLOAD_PHOTO_ID == requestCode) { } } public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); menu.add(0, TAKE_PHOTO_ID,0, R.string.take_photo); menu.add(0, UPLOAD_PHOTO_ID,0, R.string.upload_photo); menu.add(0, BACK_ID,0, R.string.back_button); return true; } //@Override public boolean onMenuItemSelected(int featureId, MenuItem item) { boolean result = true; switch(item.getItemId()) { case TAKE_PHOTO_ID: Log.i("info", "ready to take photos!"); Intent i = new Intent("android.media.action.IMAGE_CAPTURE"); startActivityForResult(i, TAKE_PHOTO_ID); result = true; break; case UPLOAD_PHOTO_ID: uploadFile2Svr(); break; case BACK_ID: this.finish(); break; default: result = super.onMenuItemSelected(featureId, item); break; } return result; } public void uploadFile2Svr() { HttpClient httpclient = new DefaultHttpClient(); String urlStr = new StringBuffer().append(HTTP_PROTOCOL) .append(/*SERVER_IP*/ConfigWindow.getServerIp()) .append(':') .append(/*SERVER_PORT*/ConfigWindow.getServerPort()) .append(FILE_UPLOADER_URL) .toString(); HttpPost httppost = new HttpPost(urlStr); String uploadMsg = "上传 照片失败!"; try { List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(); // Your DATA nameValuePairs.add(new BasicNameValuePair("filename", ("IMAGE.jpg")) ); // nameValuePairs.add(new BasicNameValuePair("orderno", "1")); // nameValuePairs.add(new BasicNameValuePair("userid", "123")); // nameValuePairs.add(new BasicNameValuePair("attach_type", "1")); // httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs)); File aFile = new File(photoPath); Log.i("info -- photoPath: ", photoPath); FileEntity fileEty = new FileEntity(aFile, "binary/octet-stream"); httppost.setEntity(fileEty); httppost.addHeader("filename", /*("IMAGE.jpg")*/aFile.getName()); HttpResponse response; response = httpclient.execute(httppost); //Log.i("info -- response: ", response.getStatusLine().getReasonPhrase()); Header[] headers = response.getAllHeaders(); headers = response.getHeaders("resultcode"); if (headers[0].getValue().equals("0")) { uploadMsg = "上传照片成功!"; } } catch (UnsupportedEncodingException e) { //e.printStackTrace(); uploadMsg += e.toString(); Log.e("exception", e.toString()); } catch (ClientProtocolException e) { //e.printStackTrace(); uploadMsg += e.toString(); Log.e("exception", e.toString()); } catch (IOException e) { //e.printStackTrace(); uploadMsg += e.toString(); Log.e("exception", e.toString()); } finally { Toast.makeText(PhotoUpload.this, uploadMsg, Toast.LENGTH_LONG).show(); httpclient.getConnectionManager().shutdown(); } } public void uploadFile2Svr2() { BufferedReader in = null; HttpClient httpclient = new DefaultHttpClient(); String urlStr = new StringBuffer().append(HTTP_PROTOCOL) .append(ConfigWindow.getServerIp()) .append(ConfigWindow.getServerPort()) .append(FILE_UPLOADER_URL) .toString(); URL url = null; try { url = new URL(urlStr); } catch (MalformedURLException e1) { e1.printStackTrace(); } HttpURLConnection conn = null; DataOutputStream dos = null; String lineEnd = "\r\n"; String twoHyphens = "--"; String boundary = "*****"; int maxBufferSize = 16 * 1024; try { // List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(); // // Your DATA // nameValuePairs.add(new BasicNameValuePair("filename", getDatedFName("IMAGE.jpg")) ); // nameValuePairs.add(new BasicNameValuePair("orderno", "1")); // nameValuePairs.add(new BasicNameValuePair("userid", "123")); // nameValuePairs.add(new BasicNameValuePair("attach_type", "1")); //httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs)); // Open a HTTP connection to the URL conn = (HttpURLConnection) url.openConnection(); conn.setConnectTimeout(120000); // Allow Inputs conn.setDoInput(true); // Allow Outputs conn.setDoOutput(true); // Don't use a cached copy. conn.setUseCaches(false); // Use a post method. conn.setRequestMethod("POST"); conn.setRequestProperty("Connection", "Keep-Alive"); conn.setRequestProperty("Content-Type", //"multipart/form-data;boundary=" + boundary); "application/x-www-form-urlencoded"); conn.setRequestProperty("user-agent", "Mozilla/5.0 (Windows; U; Windows NT 5.2; zh-CN; rv:1.9.1.6) Gecko/20091201 Firefox/3.5.6 GTB6"); //conn.setRequestProperty("accept-language", "zh-cn,zh;q=0.5"); //conn.setRequestProperty("Content-Type", "multipart/form-data;boundary="+ boundary); conn.connect(); //OutputStream connOs = conn.getOutputStream(); dos = new DataOutputStream(conn.getOutputStream()); dos.writeBytes(twoHyphens + boundary + lineEnd); dos.writeBytes("Content-Disposition: form-data; name=\"uploadedfile\";filename=\"" + "exsistingFileName" + "\"" + lineEnd); //dos.writeBytes(lineEnd); Log.i("info", "Headers are written"); // upload file to webserver via http FileInputStream fileInputStream = new FileInputStream(photoPath); // create a buffer of maximum size int bytesAvailable = fileInputStream.available(); int bufferSize = Math.min(bytesAvailable, maxBufferSize); byte[] buffer = new byte[bufferSize]; // read file and write it into form... int bytesRead = fileInputStream.read(buffer, 0, bufferSize); while (bytesRead > 0) { dos.write(buffer, 0, bufferSize); bytesAvailable = fileInputStream.available(); bufferSize = Math.min(bytesAvailable, maxBufferSize); bytesRead = fileInputStream.read(buffer, 0, bufferSize); } // send multipart form data necesssary after file data... dos.writeBytes(lineEnd); dos.writeBytes(twoHyphens + boundary + twoHyphens + lineEnd); // close streams Log.e("info", "File is written"); fileInputStream.close(); dos.flush(); dos.close(); dos = null; // response // HttpResponse response; // response = httpclient.execute(httppost); // response = httpclient.execute(conn.get); in = new BufferedReader( new InputStreamReader(conn.getInputStream())); StringBuffer sb = new StringBuffer(""); String line = ""; String NL = System.getProperty("line.separator"); while ((line = in.readLine()) != null) { sb.append(line + NL); } in.close(); String result = sb.toString(); Log.i("info", result); } catch (ClientProtocolException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } finally{ if(in != null){ try{ in.close(); }catch(IOException ioe){ Log.e("error", ioe.toString()); } } } } public static String getDatedFName(String fname) { StringBuffer result = new StringBuffer(); SimpleDateFormat df = new SimpleDateFormat("yyMMddHHmmss"); String dateSfx = "_" + df.format(new Date()); int idx = fname.lastIndexOf('.'); if (idx != -1) { result.append(fname.substring(0, idx)); result.append(dateSfx); result.append(fname.substring(idx)); } else { result.append(fname); result.append(dateSfx); } return result.toString(); } //============================================= //private Bitmap photoCaptured; private String photoPath = "/sdcard/IMAGE_100225083437.jpg"; //"/sdcard/1.txt"; private static final int TAKE_PHOTO_ID = Menu.FIRST; private static final int UPLOAD_PHOTO_ID = Menu.FIRST + 1; private static final int BACK_ID = Menu.FIRST + 3; private static final String HTTP_PROTOCOL = "http://"; private static final String FILE_UPLOADER_URL = "/fileuploader/system/fileUpload"; private String SD_CARD_TEMP_DIR = Environment.getExternalStorageDirectory() + File.separator + "IMG.jpg"; } 4. ConfigWindow.java--系统配置窗口 view plaincopy to clipboardprint? package com.hemi.rhet; import com.hemi.rhet.R; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.util.Log; import android.view.KeyEvent; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.CheckBox; import android.widget.EditText; public class ConfigWindow extends Activity { @Override public void onCreate(Bundle savedInstanceState) { System.out.println("enter ConfigWindow.onCreate()!"); super.onCreate(savedInstanceState); setContentView(R.layout.config_window); mServerIP = (EditText)findViewById(R.id.serverip); mServerPort = (EditText)findViewById(R.id.serverport); //hemerr mServerIP.setText(serverIp); mServerPort.setText(serverPort); okButton = (Button) findViewById(R.id.ok_button); backButton = (Button) findViewById(R.id.back_button); loginBtnListener = new View.OnClickListener() { public void onClick(View view) { if (view == okButton) { serverIp = mServerIP.getText().toString(); serverPort = mServerPort.getText().toString(); Log.i("info", "IP is: "+serverIp+"\tPort is: "+serverPort); finish(); } else if(view == backButton) { finish(); } } }; okButton.setOnClickListener(loginBtnListener); backButton.setOnClickListener(loginBtnListener); } private void launchFetion() { Intent i = new Intent(this, FuncSelector.class); i.putExtra(KEY_LOGIN_NAME, mServerIP.getText().toString()); i.putExtra(KEY_LOGIN_PASSWD, mServerPort.getText().toString()); startActivity(i); } @Override public boolean onKeyDown(int keyCode, KeyEvent msg) { // System.out.println("enter onKeyDown() in LoginWindow!"); // // if (null != loginBtnListener) { // View aview = getCurrentFocus(); // loginBtnListener.onClick(aview); // } return false; } public static String getServerIp() { return serverIp; } public static String getServerPort() { return serverPort; } private Button okButton, backButton; private EditText mServerIP; private EditText mServerPort; private OnClickListener loginBtnListener; public static final String KEY_LOGIN_NAME = "login_name"; public static final String KEY_LOGIN_PASSWD = "login_passwd"; public static final String KEY_LOGIN_TYPE = "login_type"; public static String serverIp = "192.168.0.98"; //; public static String serverPort = "8081"; } 还需要增加bg_logo.jpg、icon.png、photo_upload.png等几个图片。
配置
1. login_window.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/bg_logo"
>
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dip"
android:layout_marginRight="20dip"
android:text="@string/user_name"
/>
<EditText
android:id="@+id/username"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dip"
android:layout_marginRight="20dip"
android:scrollHorizontally="true"
android:autoText="false"
android:text="user"
android:capitalize="none"
android:gravity="fill_horizontal"
android:textAppearance="?android:attr/textAppearanceMedium"
/>
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dip"
android:layout_marginRight="20dip"
android:text="@string/user_passwd" />
<EditText android:id="@+id/userpasswd"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dip"
android:layout_marginRight="20dip"
android:scrollHorizontally="true"
android:autoText="false"
android:text="user"
android:capitalize="none"
android:gravity="fill_horizontal"
android:password="true"
android:textAppearance="?android:attr/textAppearanceMedium" />
<CheckBox android:id="@+id/cbx_cmwap"
android:text="CMWAP"
android:checked="false"
android:layout_marginLeft="20dip"
android:layout_marginRight="20dip"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<RelativeLayout android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<Button android:id="@+id/login_button"
android:text="LOGIN"
android:layout_marginLeft="20dip"
android:layout_marginRight="20dip"
android:layout_alignParentRight="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<Button android:id="@+id/exit_button"
android:text="EXIT"
android:layout_marginLeft="20dip"
android:layout_marginRight="20dip"
android:layout_toLeftOf="@id/login_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</RelativeLayout>
</LinearLayout>
2. func_selector.xml
<?xml version="1.0" encoding="utf-8"?>
<GridView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/func_selector"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:numColumns="auto_fit"
android:verticalSpacing="10dp"
android:horizontalSpacing="10dp"
android:columnWidth="90dp"
android:stretchMode="columnWidth"
android:gravity="center"
android:background="@drawable/bg_logo"
/>
3. night_item.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content"
android:paddingBottom="4dip" android:layout_width="fill_parent">
<ImageView
android:layout_height="wrap_content"
android:id="@+id/ItemImage"
android:layout_width="wrap_content"
android:layout_centerHorizontal="true">
</ImageView>
<TextView
android:layout_width="wrap_content"
android:layout_below="@+id/ItemImage"
android:layout_height="wrap_content"
android:text="TextView01"
android:layout_centerHorizontal="true"
android:id="@+id/ItemText">
</TextView>
</RelativeLayout>
4. config_window.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dip"
android:layout_marginRight="20dip"
android:text="@string/server_ip"
/>
<EditText
android:id="@+id/serverip"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dip"
android:layout_marginRight="20dip"
android:scrollHorizontally="true"
android:autoText="false"
android:capitalize="none"
android:gravity="fill_horizontal"
android:textAppearance="?android:attr/textAppearanceMedium"
/>
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dip"
android:layout_marginRight="20dip"
android:text="@string/server_port" />
<EditText android:id="@+id/serverport"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dip"
android:layout_marginRight="20dip"
android:scrollHorizontally="true"
android:autoText="false"
android:capitalize="none"
android:gravity="fill_horizontal"
android:textAppearance="?android:attr/textAppearanceMedium" />
<RelativeLayout android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<Button android:id="@+id/ok_button"
android:text="@string/ok_button"
android:layout_marginLeft="20dip"
android:layout_marginRight="20dip"
android:layout_alignParentRight="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<Button android:id="@+id/back_button"
android:text="@string/back_button"
android:layout_marginLeft="20dip"
android:layout_marginRight="20dip"
android:layout_toLeftOf="@id/ok_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</RelativeLayout>
</LinearLayout>
5. AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.hemi.rhet" android:versionCode="1" android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:label="@string/app_name" android:name="LoginWindow">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="FuncSelector"></activity>
<activity android:name="PhotoUpload"></activity>
<activity android:name="ConfigWindow"></activity>
</application>
<uses-sdk android:minSdkVersion="5"/>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>
</manifest>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/bg_logo"
>
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dip"
android:layout_marginRight="20dip"
android:text="@string/user_name"
/>
<EditText
android:id="@+id/username"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dip"
android:layout_marginRight="20dip"
android:scrollHorizontally="true"
android:autoText="false"
android:text="user"
android:capitalize="none"
android:gravity="fill_horizontal"
android:textAppearance="?android:attr/textAppearanceMedium"
/>
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dip"
android:layout_marginRight="20dip"
android:text="@string/user_passwd" />
<EditText android:id="@+id/userpasswd"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dip"
android:layout_marginRight="20dip"
android:scrollHorizontally="true"
android:autoText="false"
android:text="user"
android:capitalize="none"
android:gravity="fill_horizontal"
android:password="true"
android:textAppearance="?android:attr/textAppearanceMedium" />
<CheckBox android:id="@+id/cbx_cmwap"
android:text="CMWAP"
android:checked="false"
android:layout_marginLeft="20dip"
android:layout_marginRight="20dip"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<RelativeLayout android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<Button android:id="@+id/login_button"
android:text="LOGIN"
android:layout_marginLeft="20dip"
android:layout_marginRight="20dip"
android:layout_alignParentRight="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<Button android:id="@+id/exit_button"
android:text="EXIT"
android:layout_marginLeft="20dip"
android:layout_marginRight="20dip"
android:layout_toLeftOf="@id/login_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</RelativeLayout>
</LinearLayout>
2. func_selector.xml
<?xml version="1.0" encoding="utf-8"?>
<GridView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/func_selector"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:numColumns="auto_fit"
android:verticalSpacing="10dp"
android:horizontalSpacing="10dp"
android:columnWidth="90dp"
android:stretchMode="columnWidth"
android:gravity="center"
android:background="@drawable/bg_logo"
/>
3. night_item.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content"
android:paddingBottom="4dip" android:layout_width="fill_parent">
<ImageView
android:layout_height="wrap_content"
android:id="@+id/ItemImage"
android:layout_width="wrap_content"
android:layout_centerHorizontal="true">
</ImageView>
<TextView
android:layout_width="wrap_content"
android:layout_below="@+id/ItemImage"
android:layout_height="wrap_content"
android:text="TextView01"
android:layout_centerHorizontal="true"
android:id="@+id/ItemText">
</TextView>
</RelativeLayout>
4. config_window.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dip"
android:layout_marginRight="20dip"
android:text="@string/server_ip"
/>
<EditText
android:id="@+id/serverip"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dip"
android:layout_marginRight="20dip"
android:scrollHorizontally="true"
android:autoText="false"
android:capitalize="none"
android:gravity="fill_horizontal"
android:textAppearance="?android:attr/textAppearanceMedium"
/>
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dip"
android:layout_marginRight="20dip"
android:text="@string/server_port" />
<EditText android:id="@+id/serverport"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dip"
android:layout_marginRight="20dip"
android:scrollHorizontally="true"
android:autoText="false"
android:capitalize="none"
android:gravity="fill_horizontal"
android:textAppearance="?android:attr/textAppearanceMedium" />
<RelativeLayout android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<Button android:id="@+id/ok_button"
android:text="@string/ok_button"
android:layout_marginLeft="20dip"
android:layout_marginRight="20dip"
android:layout_alignParentRight="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<Button android:id="@+id/back_button"
android:text="@string/back_button"
android:layout_marginLeft="20dip"
android:layout_marginRight="20dip"
android:layout_toLeftOf="@id/ok_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</RelativeLayout>
</LinearLayout>
5. AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.hemi.rhet" android:versionCode="1" android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:label="@string/app_name" android:name="LoginWindow">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="FuncSelector"></activity>
<activity android:name="PhotoUpload"></activity>
<activity android:name="ConfigWindow"></activity>
</application>
<uses-sdk android:minSdkVersion="5"/>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>
</manifest>
发表评论
-
更改Android AVD模拟器创建路径位置的方法
2013-03-21 10:37 1306Win7下更改Android AVD模拟器创建路 ... -
This Android SDK requires Android Developer Toolkit version 20.0.0 or above
2013-03-21 10:09 916本人最近在操作更新ANDR ... -
利用adb为android手机安装软件
2011-07-26 17:15 1040本文主要是记录一下在 ... -
Android adb的使用略解
2011-07-21 16:34 1045安卓网的一个帖子,写得不错,记下来 ADB全称Andro ... -
Windows平台下ADB的安装与使用
2011-07-21 16:31 1264Android SDK(如觉SDK文件过大,也可以只准备G1 ... -
[Android算法] http 上传文件的方法
2011-06-03 21:19 1685/** * ... -
android拍照上传的效果是如何实现的
2011-06-01 16:52 1452Intent i = new Intent(Intent.AC ...
相关推荐
这个名为“Android拍照上传代码样例app_安卓源码.zip”的压缩包文件提供了一个实际的代码示例,可以帮助开发者理解并实施这一功能。接下来,我们将深入探讨涉及到的关键知识点。 1. **AndroidManifest.xml配置**:...
在Android平台上,拍照并上传至服务器是常见的功能...通过以上步骤,一个完整的Android拍照上传功能就能实现了。在实际开发中,还可以根据具体需求添加更多的功能,如裁剪图片、选择本地相册中的图片、支持多图上传等。
在提供的压缩包文件“Android拍照上传代码样例(转)”中,你可能找到一个完整的示例项目,包括了上述步骤的具体实现。通过阅读和学习这个样例代码,你可以更好地理解和掌握Android拍照和上传功能的实现细节。记住,...
Android安卓项目源码-拍照上传代码样例(转).zip
在Android平台上,拍照上传功能是常见的应用场景,例如社交媒体分享、在线文档编辑等。...在压缩包中的"拍照上传代码样例(转)"文件可能包含更具体的实现细节,你可以参考其中的代码来理解和实践这些知识点。
本资源“Android应用源码之拍照上传代码样例(转.zip”提供了一个具体的示例,帮助开发者理解和实现这个过程。下面将详细讲解其中涉及的关键知识点。 1. 拍照功能: - `Intent`使用:在Android中,启动相机应用通常...
下面将详细讲解这个“Android应用源码之拍照上传代码样例”所涵盖的关键知识点。 1. **Android权限管理**: 在Android中,访问相机和存储空间都需要申请相应的权限。在Android 6.0(API级别23)及更高版本,需要在...
在Android应用开发中,拍照并上传功能是常见的需求,尤其在社交、电商或者任何需要用户上传图片的应用中。本教程将深入探讨如何实现这一功能,通过一个简单的代码样例来帮助开发者理解整个流程。 首先,我们需要在...
在安卓(Android)开发中,...总的来说,这个代码样例涵盖了从启动相机、获取图片、保存图片到本地、上传图片到服务器以及处理相关权限和错误的基本流程。开发者可以参考这个样例,根据实际项目需求进行调整和优化。
通过这样的Demo,开发者可以快速验证拍照和相册选图功能的实现,同时也可以作为学习和参考的样例代码。在开发过程中,还需要注意兼容不同设备和系统版本,以及优化用户体验,如加载速度、图片质量等。 总之,“拍照...