1. 程式人生 > >移動開發大作業————隨手記(主介面和編輯介面)

移動開發大作業————隨手記(主介面和編輯介面)

功能需求

隨手記的功能

1編輯增加筆記

2.自由檢視修改儲存的筆記

3.自由填寫文字和圖片

主介面編寫



MainActivity.java

package com.cong.notepad;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Timer;
import java.util.TimerTask;
import android.os.Bundle;
import android.os.Environment;
import android.app.Activity;
import android.content.Intent;
import android.database.Cursor;
import android.util.Log;
import android.view.ContextMenu;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.View.OnClickListener;
import android.view.View.OnCreateContextMenuListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ImageButton;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
public class MainActivity extends Activity {
	private TextView addtravels;
	private ListView travelslist;
	private DBManage dm=null;
	private HTMLManager HM=null;
	public Cursor cursor = null;
	public Cursor cursor2=null;
	private int i=0;
	private int start=0;
	private int end=0;
	private String str1=null;
	private String str2="[";
	private String str4="]";
	private String iconname=null;
	private File copyfromfile=null;
	private File copyintofile=null;
	private FileOutputStream copyinto=null;
	private FileInputStream copyfrom=null;
	private ListViewAdd adapter;// 資料來源物件
	private static Boolean isExit = false;  
    private static Boolean hasTask = false;
	public static final String CHECK_STATE = "0";
	public static final String EDIT_STATE = "1";
	public static final String ALERT_STATE = "2";
    Timer tExit = new Timer();  
    TimerTask task = new TimerTask() {  
        @Override  
        public void run() {  

            isExit = true;  

            hasTask = true;  
        }  
    }; 
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        addtravels=(TextView)findViewById(R.id.addtravels);
        addtravels.setOnClickListener(new addListener());
        travelslist=(ListView)findViewById(R.id.travelslist);
        dm=new DBManage(this);
        HM=new HTMLManager();
        initAdapter();       
        travelslist.setAdapter(adapter);
        travelslist.setOnItemClickListener(new myOnItemClickListener());
        travelslist.setOnCreateContextMenuListener(new myOnCreateContextMenuListener());//設定長按監聽器
    }
    class addListener implements OnClickListener{

		public void onClick(View v) {
			// TODO Auto-generated method stub
			Intent intent=new Intent();
			intent.setClass(MainActivity.this, edittravels.class);
			intent.putExtra("state", EDIT_STATE);
			startActivity(intent);
			finish();
		}
    	
    }

	public void initAdapter(){
    	
    	dm.open();//開啟資料庫操作物件
    	
    	cursor = dm.selectAll();//獲取所有資料
    	
    	cursor.moveToFirst();//將遊標移動到第一條資料,使用前必須呼叫
    	
    	int count = cursor.getCount();//個數
    	
    	ArrayList<String> items = new ArrayList<String>();
    	ArrayList<String> times = new ArrayList<String>();
    	for(int i= 0; i < count; i++){
    		items.add(cursor.getString(cursor.getColumnIndex("title")));
    		times.add(cursor.getString(cursor.getColumnIndex("time")));
    		cursor.moveToNext();//將遊標指向下一個
    	}
    	dm.close();//關閉資料操作物件
    	adapter = new ListViewAdd(this,items,times);//建立資料來源
    }
	public class myOnCreateContextMenuListener implements OnCreateContextMenuListener{

		public void onCreateContextMenu(ContextMenu menu, View v,ContextMenuInfo menuInfo) {
			// TODO Auto-generated method stub
			final AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;
			menu.setHeaderTitle("");
			//設定選項
			Log.i("log", "chooseing menu");
			menu.add(0,0,0,"刪除");
			menu.add(0,1,0,"修改");
			menu.add(0,2,0,"檢視");
			menu.add(0,3,0,"匯出到SD卡");
		}
		
	}
	public boolean onContextItemSelected(MenuItem item){
		AdapterView.AdapterContextMenuInfo menuInfo = (AdapterView.AdapterContextMenuInfo)item.getMenuInfo();
		dm.open();
    	switch(item.getItemId()){
		case 0://刪除
			Log.i("log", "selectItem---->"+item.getItemId());
			try{
				Log.i("log", "cursor ready move ");
				Log.i("log", "menuInfo position "+menuInfo.position);
				
				cursor.moveToPosition(menuInfo.position);
				
				Log.i("log", "cursor move success");
				int i = dm.delete(Long.parseLong(cursor.getString(cursor.getColumnIndex("_id"))));//刪除資料
				
				adapter.removeListItem(menuInfo.position);//刪除資料
				adapter.notifyDataSetChanged();//通知資料來源,資料已經改變,重新整理介面
				dm.close();
			}catch(Exception ex){
				ex.printStackTrace();
			}
			break;
    	case 1://修改
    		//	Log.v("show", "chenggong2");
    			try{
    				cursor.moveToPosition(menuInfo.position);
    				
    				//用於Activity之間的通訊
    				Intent intent = new Intent();
    				//通訊時的資料傳送
    				intent.putExtra("id", cursor.getString(cursor.getColumnIndex("_id")));
    				intent.putExtra("state", ALERT_STATE);
    				intent.putExtra("title", cursor.getString(cursor.getColumnIndex("title")));
    				intent.putExtra("time", cursor.getString(cursor.getColumnIndex("time")));
    				intent.putExtra("content", cursor.getString(cursor.getColumnIndex("content")));
    				//設定並啟動另一個指定的Activity
    				intent.setClass(MainActivity.this, edittravels.class);
    				MainActivity.this.startActivity(intent);
    				finish();
    			     }catch(Exception ex){
    				ex.printStackTrace();
    			    }
    			break;
    		case 2://檢視
    		//	Log.v("show", "chenggong3");
    			try{
    				cursor.moveToPosition(menuInfo.position);
    				
    				Intent intent = new Intent();
    				
    				intent.putExtra("id", cursor.getString(cursor.getColumnIndex("_id")));
    				intent.putExtra("title", cursor.getString(cursor.getColumnIndex("title")));
    				intent.putExtra("time", cursor.getString(cursor.getColumnIndex("time")));
    				intent.putExtra("content", cursor.getString(cursor.getColumnIndex("content")));
    				
    				intent.setClass(MainActivity.this, checktravels.class);
    				MainActivity.this.startActivity(intent);
    			}catch(Exception ex){
    				ex.printStackTrace();
    			}
    			break;
    		case 3:
    			try{
    				cursor.moveToPosition(menuInfo.position);
    				String title=cursor.getString(cursor.getColumnIndex("title"));
    				String content=cursor.getString(cursor.getColumnIndex("content"));
    				HM.htmlmanager(title, content);
    				copyicon(title,content);
    				Toast.makeText(MainActivity.this, "匯出成功,快去SD卡的\" 隨手記 \"裡找出來分享吧!!", Toast.LENGTH_LONG).show();
    			}catch(Exception ex){
    				Toast.makeText(MainActivity.this, "Sorry!!!匯出失敗!!", Toast.LENGTH_LONG).show();
    				ex.printStackTrace();
    			}
    			break;
    		default:;
    		}
    	dm.close();
		return super.onContextItemSelected(item);
    }
	public int copyicon(String title1,String content1){
		 for(i=0;i<content1.length();i++)
		 {
			 str1=content1.substring(i, i+1);
			 if(str1.equals(str2))
			 {
				 start=i+1;
			 }
			 if(str1.equals(str4))
			 {
				 end=i;
				 iconname=content1.substring(start, end);
				 Log.i("log", iconname);
				 cursor2=dm.selcetPathByName(iconname);
				 cursor2.moveToFirst();
				 String iconpath2=cursor2.getString(cursor2.getColumnIndex("path"));
				 Log.i("log", iconpath2);
				 cursor2.close();
				 copyfromfile=new File(iconpath2);
				 String copyintopath="/mnt/sdcard/隨手記/"+title1+"/"+iconname;
				 Log.i("log", copyintopath);
				 copyfile(iconpath2,copyintopath);
			 } 
		 }
		 return 0;
	}
	public int copyfile(String from,String into){
		try
		{
		 copyfrom=new FileInputStream(from);
		 copyinto=new FileOutputStream(into);
		 Log.i("log", "fuck you");
		 byte[] bt = new byte[1024];  
            int c;  
            while((c=copyfrom.read(bt)) > 0){  
                copyinto.write(bt,0,c);
            }
            copyfrom.close();
            copyinto.close();
            Log.i("log", "copy success");
            return 1;
	 }catch (FileNotFoundException e) {  
         // TODO Auto-generated catch block
		 e.printStackTrace();
		 return -1;
          
     } catch (IOException e) {  
         // TODO Auto-generated catch block
    	 e.printStackTrace();
    	 return -1;
           
     }  
	}
	
	//短按,即點選
	public class myOnItemClickListener implements OnItemClickListener{
	public void onItemClick(AdapterView<?> arg0, View v, int position, long id) {
		// TODO Auto-generated method stub
		//super.onListItemClick(l, v, position, id);
		Log.i("log", "position--->"+position);
		cursor.moveToPosition(position);
		Intent intent = new Intent();
		intent.putExtra("state", CHECK_STATE);
		intent.putExtra("id", cursor.getString(cursor.getColumnIndex("_id")));
		intent.putExtra("title", cursor.getString(cursor.getColumnIndex("title")));
		intent.putExtra("content", cursor.getString(cursor.getColumnIndex("content")));
		intent.putExtra("time", cursor.getString(cursor.getColumnIndex("time")));
		intent.setClass(MainActivity.this, checktravels.class);
		MainActivity.this.startActivity(intent);
	}
	}
	@Override
	protected void onDestroy() {
		// TODO Auto-generated method stub
		cursor.close();
		super.onDestroy();
	}
  
	   public  boolean onKeyDown(int keyCode, KeyEvent event) {  //按兩次返回退出

           // TODO Auto-generated method stub  

           if(keyCode == KeyEvent.KEYCODE_BACK){  

                   System.out.println(isExit);  

                   if(isExit == false ) {  

                           isExit = true;  
                           System.out.println("isexit1 "+isExit);  

                           Toast.makeText(this, "再按一次退出程式", Toast.LENGTH_SHORT).show();  
                           System.out.println("isexit2 "+isExit);  

                           if(!hasTask) {
                            	System.out.println("hastask "+hasTask);  

                               tExit.schedule(task, 2000);  
                           }} else {
                           	finish();  
                               System.exit(0);
                               }  
                             
                   }
           return false;
}
}
佈局檔案


activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/background"
    android:orientation="vertical" >

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="40dip"
        android:background="@drawable/lable" >

        <TextView
            android:id="@+id/textview"
            android:layout_width="150dip"
            android:layout_height="40dip"
            android:layout_centerHorizontal="true"
            android:layout_centerVertical="true"
            android:layout_marginTop="5dp"
            android:text="  隨  手   記"
            android:textColor="#99CC00"
            android:textSize="24sp"
            android:textStyle="bold" >
        </TextView>

        <TextView
            android:id="@+id/addtravels"
            android:layout_width="35dip"
            android:layout_height="38dip"
            android:layout_alignParentRight="true"
            android:layout_marginTop="2dip"
            android:background="@drawable/writeicon" >
        </TextView>
    </RelativeLayout>

    <ListView
        android:id="@+id/travelslist"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" >
    </ListView>

</LinearLayout>


編輯介面編寫


edittravels.java

package com.cong.notepad;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Calendar;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import android.app.Activity;
import android.content.ContentResolver;
import android.content.Intent;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Matrix;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.media.ExifInterface;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.provider.MediaStore;
import android.provider.MediaStore.MediaColumns;
import android.text.Editable;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.Html.ImageGetter;
import android.text.format.DateFormat;
import android.text.style.ImageSpan;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.Toast;

public class edittravels extends Activity{
	private static final int SELECT_IMAGE =123;
	int rotate = 0; 
	private EditText titleedit;
	private EditText travelsedit;
	private ImageButton save;
	private ImageButton insertimage;
	private ImageButton takephoto;
	private String idString;
	private int id2;
	private String title="";
	private String travelsdata = "";
	private String timeText = "";
	public Cursor cursor=null;
	public String namestr="";
	private DBManage dm=null;
	private Bitmap bitmap = null;
	private String path = null;
	private int state =-1;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.edittravels);
		titleedit=(EditText)findViewById(R.id.titleedit);
		travelsedit=(EditText)findViewById(R.id.travelsedit);
		save=(ImageButton)findViewById(R.id.save);
		save.setOnClickListener(new saveListener());
		insertimage=(ImageButton)findViewById(R.id.insertimage);
		insertimage.setOnClickListener(new insertimageListener());
		dm=new DBManage(this);
		Intent intent = getIntent();
		state = Integer.parseInt(intent.getStringExtra("state"));
		Log.i("log", "state---->"+state);
		if (state==2)
		{
			idString =intent.getStringExtra("id");
			Log.i("log", "id---->"+idString);
			id2 =  Integer.parseInt(idString);
			title = intent.getStringExtra("title");
			travelsdata = intent.getStringExtra("content");
			timeText = intent.getStringExtra("time");
			titleedit.setText(title);
			dm.open();
			int i=0;
			int start=0;
			int end=0;
			String str1=null;
			String str2="[";
			String str4="]";
			String iconname=null;
			SpannableString travelsSpan =new SpannableString(travelsdata);
			for(i=0;i<travelsdata.length();i++)
			{
				str1=travelsdata.substring(i, i+1);
				//travelsString+=str1;
				Log.i("log", str1);
				if(str1.equals(str2))
				{
					start=i+1;
				}
				if(str1.equals(str4))
				{
					end=i;
				namestr=travelsdata.substring(start,end);
				Log.i("log", namestr);
				cursor=dm.selcetPathByName(namestr);
				cursor.moveToFirst();
				path=cursor.getString(cursor.getColumnIndex("path"));
				cursor.close();
				namestr=null;
				Log.i("log", path);
				if(!(cursor==null))
				{
					int count=cursor.getCount();
					Log.i("log", "count----->"+count);
					BitmapFactory.Options options =new BitmapFactory.Options();
					options.inJustDecodeBounds =true;
					bitmap =BitmapFactory.decodeFile(path, options); //此時返回bm為空
					options.inJustDecodeBounds =false;
					int be = (int)(options.outHeight/ (float)100);
					if (be <= 0)
						be = 1;
					options.inSampleSize = be;
					bitmap=BitmapFactory.decodeFile(path,options);
					Drawable drawable = new BitmapDrawable(bitmap);
					drawable.setBounds(0, 0, 360, 280);
					ImageSpan span = new ImageSpan(drawable,ImageSpan.ALIGN_BOTTOM);
					travelsSpan.setSpan(span, start-1,end+1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
				}
				else
				{
					Log.i("log", "insert icon faile");
				}
				}
				
				}
			dm.close();	
			travelsedit.setText(travelsSpan);
		}
	}
	//儲存按鈕點選事件
	class saveListener implements OnClickListener{

		

		public void onClick(View v) {
			// TODO Auto-generated method stub
			title = titleedit.getText().toString();
			travelsdata= travelsedit.getText().toString();
			Log.i("log","title---->"+title);
			Log.i("log", "travels---->"+travelsdata);
				try{
					dm.open();
					if(state==1)					
					dm.insert(title, travelsdata);
					if (state==2)
					Log.i("log", "ready to alter");
					dm.update(id2, title, travelsdata);
					dm.close();
				}catch(Exception ex){
					ex.printStackTrace();
				}
				Intent gobackIntent=new Intent(edittravels.this,MainActivity.class);
				edittravels.this.startActivity(gobackIntent);
				finish();
		}
		
	}
	//插入圖片點選事件
	class insertimageListener implements OnClickListener{

		public void onClick(View v) {
			// TODO Auto-generated method stub
			//Intent getImage = new Intent(Intent.ACTION_PICK,
					//MediaStore.Images.Media.INTERNAL_CONTENT_URI);
			//startActivityForResult(getImage, SELECT_IMAGE);
			Intent intent=new Intent(Intent.ACTION_GET_CONTENT);
			  intent.addCategory(Intent.CATEGORY_OPENABLE);
			  intent.setType("image/*");
			  intent.putExtra("return-data", true);
			  startActivityForResult(intent, SELECT_IMAGE);
		}
		
	}

	@Override
	protected void onActivityResult(int requestCode, int resultCode, Intent data) {
		super.onActivityResult(requestCode, resultCode, data);
		
		if (resultCode == RESULT_OK)
		{
			path=getpath(data.getData());
		BitmapFactory.Options options =new BitmapFactory.Options();
				        options.inJustDecodeBounds =true;
				         //獲取這個圖片的寬和高
				       bitmap =BitmapFactory.decodeFile(path, options); //此時返回bm為空
				        options.inJustDecodeBounds =false;			      
				         //計算縮放比
				        int be = (int)(options.outHeight/ (float)100);
				        if (be <= 0)
				            be = 1;
				        options.inSampleSize = be;
				        Log.i("log","be---->"+be);
				        //重新讀入圖片
				       bitmap=BitmapFactory.decodeFile(path,options);
				       int bitmapwidth=options.outWidth;
				       int bitmapheight=options.outHeight;
				       //檢查圖片是否要翻轉
				       try {   
				           ExifInterface exifInterface = new ExifInterface(path);   
				           int result = exifInterface.getAttributeInt(   
				                   ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_UNDEFINED);   
				             
				           switch(result) {   
				           case ExifInterface.ORIENTATION_ROTATE_90:   
				               rotate = 90; 
				               Log.i("log", "rotate----->"+rotate);
				               break;   
				           case ExifInterface.ORIENTATION_ROTATE_180:   
				               rotate = 180;   
				               Log.i("log", "rotate----->"+rotate);
				               break;   
				           case ExifInterface.ORIENTATION_ROTATE_270:   
				               rotate = 270;
				               Log.i("log", "rotate----->"+rotate);
				               break;   
				           default:   
				               break;   
				           } 
				     
				       }  catch (IOException e) {   
				           e.printStackTrace();   
				       }
				       if (rotate!=0&&bitmap!=null)
				        {
				        	Matrix matrix=new Matrix();
					        matrix.reset();
					        matrix.setRotate(rotate);
					        Bitmap bitmap1= Bitmap.createBitmap(bitmap, 0, 0, options.outWidth, options.outHeight, matrix, true);
					        bitmap = bitmap1;
					        rotate=0;
					        bitmapwidth=options.outHeight;
					        bitmapheight=options.outWidth;
				        }
				Drawable drawable = new BitmapDrawable(bitmap);
				drawable.setBounds(0, 0,bitmapwidth*2,bitmapheight*2);
				String iconname = path.substring(path.lastIndexOf("/")+1);
				String iconimfo="["+iconname+"]";
				SpannableString spannable = new SpannableString(iconimfo);
				ImageSpan span = new ImageSpan(drawable,ImageSpan.ALIGN_BOTTOM);
				spannable.setSpan(span, 0,iconimfo.length(),Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
				int select=travelsedit.getSelectionStart();
				Editable edit = travelsedit.getEditableText();
				edit.insert(select, spannable);
				try{
					dm.open();
					dm.inserticonpath(iconname, path);
					dm.close();
				}catch(Exception ex){
					ex.printStackTrace();
				}
		}
	}
	String getpath(Uri uri) {
		String[] projection = {MediaColumns.DATA};
		Cursor cursor = managedQuery(uri, projection, null, null, null);
		startManagingCursor(cursor);
		int column_index = cursor.getColumnIndexOrThrow(MediaColumns.DATA);
		// 記錄圖片的位置
		Log.i("log","column_index---->"+column_index);
		cursor.moveToFirst();
		return cursor.getString(column_index);
	}

	int poi = 0;

	@Override
	protected void onDestroy() {
		// TODO Auto-generated method stub
		super.onDestroy();
	}
	public boolean onKeyDown(int KeyCode,KeyEvent event){
		if (KeyCode==KeyEvent.KEYCODE_BACK)
		{
			Intent goBackToMainIntent=new Intent(edittravels.this,MainActivity.class);
			this.startActivity(goBackToMainIntent);
			finish();
		}
		return false;
		
	}
	
}

佈局介面

edittravels.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/background"
    android:orientation="vertical" >

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="40dip"
        android:orientation="horizontal" >

        <EditText
            android:id="@+id/titleedit"
            android:layout_width="275dip"
            android:layout_height="47dip"
            android:layout_marginLeft="2dip"
            android:background="#00000000"
            android:hint="輸入標題:" >
        </EditText>

        <ImageButton
            android:id="@+id/save"
            android:layout_width="45dip"
            android:layout_height="wrap_content"
            android:src="@drawable/saveicon" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_weight="1"
        android:orientation="vertical" >

        <EditText
            android:id="@+id/travelsedit"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_marginLeft="2dip"
            android:layout_weight="1"
            android:background="#00000000"
            android:gravity="top"
            android:hint="輸入內容:" >
        </EditText>

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="0"
            android:orientation="horizontal" >

            <ImageButton
                android:id="@+id/insertimage"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="0"
                android:src="@drawable/insericon" 
                android:visibility="visible">
            </ImageButton>
        </LinearLayout>
    </LinearLayout>

</LinearLayout>


相關推薦

移動開發作業————手記介面編輯介面

功能需求 隨手記的功能 1編輯增加筆記 2.自由檢視修改儲存的筆記 3.自由填寫文字和圖片 主介面編寫 MainActivity.java package com.cong.notepad; import java.io.File; impor

整除k的最連續子區間前綴取模2017美團筆試

alt logs sed ace closed %d gif ring color 題意:一個數n,給出n個數,再給一個數k。求能整除k的連續區間和所在區間的最大長度。bc85場1001的升級版。 題解:剛拿到題的時候沒看清是連續區間,就瞎想dp。發現連續區間後,想尺取法,

飛機作戰遊戲 1----運用H5Js製作

          飛機大作戰一          首先建立一個div將canvas包住使其居中: <div st

飛機作戰遊戲 2----運用H5Js製作

遊戲載入中狀態 遊戲載入中的圖片 用一個數組將圖片裝起來 var loading=[]; loading[0]=new Image; loading[0].src="img/game_loading1.png" load

飛機作戰遊戲 3----運用H5Js製作

遊戲執行中 我方飛機的狀態: var heros1 = []; // 飛機未被撞擊時的狀態 heros1[0] = new Image; heros1[0].src = "img/hero1.png"

Linux 手記文件操作

pan archive .gz ont file 刪除文件 微軟雅黑 fff sans 新建文件夾 mkdir 文件夾名 新建文件 touch 文件名 重命名 mv 文件名 新文件名 將/a目錄移動到/b下,並重命名為c mv /a /b/c

小知識手記

立即執行函數 無法使用 pre typeof 匿名 手記 () font 變量 1、創建函數的5種常用方法: (1)直接聲明 (2)函數表達式(這裏又可以分為匿名函數表達式和具名函數表達式) (3)使用構造函數 var give_alert = new Function(

知識手記

1 隨機圖(Random Graph) 隨機圖實際上是將給定的頂點之間隨機地連上邊,邊的產生可以依賴於不同的隨機方式,這樣就產生了不同的隨機圖模型。隨著邊概率的不同,隨機圖可能會呈現不同的屬性。 from random import randrange n = 10

淺談ArcGIS移動開發中的基本變數1:MapView、Map、Layers、GraphicsOverlay

一、MapView  二、Map        Map,程式設計中即ArcGISMap,可譯為地圖物件,主要用來承載地圖資料,ArcGISMap包含製圖資料圖層以及其它能夠定義地圖資訊的資料(例如basemaps底圖、popups彈出視窗、renderer渲染

手記1

HTTP常見狀態 200 OK 一切正常,對GET和POST請求的應答文件跟在後面 403 Forbidden 資源不可用。 404 Not Found 無法找到指定位置的資源 500 Internal Server Error

深圳手記隨手科技面經offer

看起來很蛇皮。。。。。 上上週打電話給我,好像是61那天,正在面網易,未接電話 7  8個,,沒接到他的電話。好像還有一家不知道誰的, 上週開始,給我發了筆試題,,一個xml解析的,,,偷懶

個人專案---手記

public class OkHttpUtil { public static void sendHttpRequest(final String address, final HttpCallbackListener l

Python手記 獲取目錄資訊•改

之前已經完成獲取目錄資訊的基本功能,但在內容比較多的目錄下執行結果如圖1。一個字形容就是“亂”,效果很不好,需要改進。 圖1 原始版顯示效果 首先感覺時間格式怪怪的,而且星期之類的也沒有必要顯示,所以從這裡下手。查詢手冊(Python v3.2.3--15.3)找到兩個

廣工JAVA作業——遊戲程式俄羅斯方塊

效果:1. 概述隨著時代的發展,電子遊戲逐漸出現,早起的一些桌面小遊戲風靡全球,其中就有《俄羅斯方塊》,《俄羅斯方塊》(Tetris)是一款由俄羅斯人阿列克謝·帕基特諾夫於1984年6月發明的休閒遊戲。該遊戲曾經被多家公司代理過。經過多輪訴訟後,該遊戲的代理權最終被任天堂獲得

NLP —— 圖模型條件機場Conditional random field,CRF

而在 mar 依賴 alt strong $$ href 否則 block 本文簡單整理了以下內容: (一)馬爾可夫隨機場(Markov random field,無向圖模型)簡單回顧 (二)條件隨機場(Conditional rand

ios開發之--UIDocumentInteractionController的使用實現更多分享服務

void cnblogs 實例 內容 main 華麗 例如 一個 img 最近在做項目的時候,碰到這樣一個需求,就是本地生成pdf文件,然後本地打開,經過測試發現,pdf文件是無法保存到相冊裏面的,只能存到手機裏面,鑒於蘋果的存儲機制,需要取出來,進行本地展示,可以直接傳到

網絡流初步:<最流>——核心增廣路算法

dfs space 10000+ can style 最大 strong names using 終於開始接觸網絡流了; 網絡流到底是個蝦米東東,用比較學術的話說,就是 一個有向圖 G=(V,E); 有兩個特別的點:源點s、匯點t; 圖中每條邊(u,v)

SM2算法生成的私鑰以及公鑰位數過341位65位

eba srv tar 公鑰 ref dac b16 mic 以及 Q滓痹仙3韌L湍赫一http://huiyi.docin.com/voxpf395 A1o74gw糧僨40訟傅釁http://huiyi.docin.com/vlbew6304 Oq24刑l1譖ka濫h

大數據搭建各個子項目時配置文件技巧適合CentOSUbuntu系統推薦

show 科研 對話 必備 ctrl+ 17. releases .html IV 不多說,直接上幹貨!   很多同行,也許都知道,對於我們大數據搭建而言,目前主流,分為Apache 和 Cloudera 和 Ambari。 後兩者我不多說,是公司必備和大多數高校

Web開發——HTML基礎文件網站結構

情況 擁有 navig extern 主動 value 基本 query 搜索引擎優化   參考:https://developer.mozilla.org/en-US/docs/Learn/HTML/Introduction_to_HTML/Document_and_we