Android 开发基础课程设计---手机文件管理系统

 部分代码:

Activity_main.xml



    
    

    

        

category.xml



 

     
    

        

            

            

            
 		
        
        
        
        
        

            

            

            

        

          
        
        

            

            

            

        

    

    
    
    
    
    
    
    

        

            

            

            

        

          
        
        

            

            

            

        

          
        

            

            

            

        

    
    
    
      
    
 
    

        

            

            

            

        
        
          

        

            

            

            

        
        
   		
   		  
        
        

    
 	
    

    

        

            

            

            

            

        
 		

 			

         
        

            

                

                

                

            

            

                

                

                

            

            

                

                

                

            

        

            
            
                 

                

                

                

            

            

                

                

                

            

            

                

                

                

            
            
         

            

                

                

                

            

            

                

                

                

            

            
            
        
    
   

far.xml






    

    

    

file.xml




    

        

        

ListView.xml




    

    

    
    

    
    

MainActivity.java

package com.example.filemanagera;

import android.app.Activity;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.Button;

public class MainActivity extends Activity {

    
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);//ÎÞ±êÌâÀ¸
        setContentView(R.layout.activity_main);
        Button cate=(Button)findViewById(R.id.cate);
        cate.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				FragmentManager fmanager=getFragmentManager();
				FragmentTransaction tr=fmanager.beginTransaction();
				CategoryFragment cat=new CategoryFragment();
				tr.replace(R.id.content,cat);
				tr.commit();
			}
		});
        
        Button file=(Button)findViewById(R.id.file);
        file.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				FragmentManager fmanager=getFragmentManager();
				FragmentTransaction tr=fmanager.beginTransaction();
				FileFragment fl=new FileFragment();
				tr.replace(R.id.content,fl);
				tr.commit(); 
			}
		});
        
        Button far=(Button)findViewById(R.id.far);
        far.setOnClickListener(new OnClickListener() {	
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				FragmentManager fmanager=getFragmentManager();
				FragmentTransaction tr=fmanager.beginTransaction();
				FarFragment far=new FarFragment();
				tr.replace(R.id.content,far);
				tr.commit();
			}
		});
    }
}

FileFragment.java

package com.example.filemanagera;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import android.annotation.SuppressLint;
import android.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;
import android.widget.SimpleAdapter;

@SuppressLint("NewApi")
public class FileFragment extends Fragment {
	
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		View v=inflater.inflate(R.layout.file, container,false);
		return v;
	}
	public void onActivityCreated(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onActivityCreated(savedInstanceState);
		ListView listview = (ListView) getActivity().findViewById(R.id.listView1); 
		String[] name = new String[] { "Alarms(0)", "Android(1)", "DCIM(0)", "Download(0)", "LOST.DIR(0)",
				"Movies(1)", "Music(0)", "E-mail(0)" }; 
		String[] time = new String[] { "2017-1-5下午4:30", "2017-1-5下午4:35", "2017-1-5下午4:40", "2017-1-5下午4:50", "2017-1-5下午5:00",
				"2017-1-5下午5:30", "2017-1-5下午6:30", "2017-1-5下午7:30" }; 
		List> listItems = new ArrayList>(); 
		for (int i = 0; i < name.length; i++) {
			Map map = new HashMap(); 
			map.put("name", name[i]);
			map.put("time", time[i]);
			listItems.add(map); 
		}
		
		SimpleAdapter adapter = new SimpleAdapter(getActivity(), listItems,
				R.layout.listview, new String[] { "name", "time" }, new int[] {
						R.id.name, R.id.time }); 
		listview.setAdapter(adapter); 
	}

}

截图:

Android 开发基础课程设计---手机文件管理系统_第1张图片

                                 分类浏览模块


Android 开发基础课程设计---手机文件管理系统_第2张图片

                                文件管理模块


Android 开发基础课程设计---手机文件管理系统_第3张图片

                                     远程管理模块


Android 开发基础课程设计---手机文件管理系统_第4张图片

                                         开启WiFi功能


Android 开发基础课程设计---手机文件管理系统_第5张图片

                                          选中文件


你可能感兴趣的:(Android学习笔记)