• 大小: 6.47M
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2020-12-24
  • 语言: Java
  • 标签: Android  短信  

资源简介

【实例简介】android短信功能

核心代码:

package cn.edu.siso;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import javax.xml.parsers.SAXParserFactory;
import org.xml.sax.InputSource;
import org.xml.sax.XMLReader;
import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import cn.edu.ContentProvide.Diary.DiaryColumns;
import cn.edu.Info.MyInfo;
import cn.edu.MyContentHandler.MyContentHandler;
import cn.edu.siso.WareHouselistview.SMSBsharpturn;
import cn.edu.siso.WareHouselistview.SMSFriendTab;
import cn.edu.siso.WareHouselistview.SMSHavefanTab;
import cn.edu.siso.WareHouselistview.SMSLoverTab;
import cn.edu.siso.WareHouselistview.SMSSchooljoke;
import cn.edu.siso.WareHouselistview.SMSapologize;
import cn.edu.siso.WareHouselistview.SMShumorjokes;
import cn.edu.siso.WareHouselistview.SMSlovewords;
import cn.edu.siso.WareHouselistview.SMSmylove;
import cn.edu.siso.WareHouselistview.SMSplayful;
public class WareHouseActivity extends ListActivity {
    /** Called when the activity is first created. */ 
	private List<MyInfo> mp3Infos=null;
	private ListView listview;   
	private Button back,updata;
	public static final String[] PROJECTION = new String[] { DiaryColumns._ID,DiaryColumns.TITLE, DiaryColumns.CREATED };
	private Touch touch=new Touch();
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.warehouse);
        listview=(ListView) findViewById(android.R.id.list);
        listview.setScrollingCacheEnabled(false);
        ShowListView();
        back=(Button) findViewById(R.id.back);
		updata=(Button) findViewById(R.id.updata);
		back.setOnClickListener(new backlistener());
		updata.setOnClickListener(new updatalistener());
		back.setOnTouchListener(touch);
		updata.setOnTouchListener(touch);
        }  
    private SimpleAdapter budildSimpleAdapter(List<MyInfo> mp3Infos){
    	
    	List<HashMap<String,Object>> list=new ArrayList<HashMap<String, Object>>();
		for (Iterator<MyInfo> iterator = mp3Infos.iterator(); iterator.hasNext();) {
			MyInfo mp3Info = (MyInfo) iterator.next();
			HashMap<String, Object> map=new HashMap<String, Object>();
			map.put("name", mp3Info.getName()); 
			map.put("listimageview", R.drawable.image);
			list.add(map);      
		}
		SimpleAdapter listadapter=new SimpleAdapter(this, list, R.layout.textview, 
				new String[]{"name","listimageview"},   
				new int[]{R.id.houseText,R.id.listimageview});
    	return listadapter ;
    }
    private void ShowListView(){
    	mp3Infos=pares(R.raw.information);
    	SimpleAdapter listadapter= budildSimpleAdapter(mp3Infos);
		setListAdapter(listadapter);    
	} 
    public List<MyInfo> pares(Object xmlname){
    	List<MyInfo> info=new ArrayList<MyInfo>();
    	try {
			SAXParserFactory factory=SAXParserFactory.newInstance();
			XMLReader reader=factory.newSAXParser().getXMLReader();
			MyContentHandler mycontenthandler=new MyContentHandler(info);
			reader.setContentHandler(mycontenthandler);
			reader.parse(new InputSource(getResources().openRawResource((Integer) xmlname)));
		} catch (Exception e) {
			e.printStackTrace();
		}
		return info;
    }
    
    @Override
	protected void onListItemClick(ListView l, View v, int position, long id) {
		// TODO Auto-generated method stub
    	//MyInfo myinfo=mp3Infos.get(position);
    	//System.out.println("myinfo-------" myinfo);
    	Intent intent =new Intent();
    	switch(position){
    	case 0:
    		intent.setClass(WareHouseActivity.this, SMSapologize.class);
		    startActivity(intent);
    		break;
    	case 1:
    		intent.setClass(WareHouseActivity.this, SMSmylove.class);
		    startActivity(intent);
    		break;
    	case 2:
    		intent.setClass(WareHouseActivity.this, SMSlovewords.class);
		    startActivity(intent);
    		break;
    	case 3:
    		intent.setClass(WareHouseActivity.this, SMSHavefanTab.class);
		    startActivity(intent);
		    break;
    	case 4:
		    intent.setClass(WareHouseActivity.this, SMSLoverTab.class);
		    startActivity(intent);
		    break;
    	case 5:
    		intent.setClass(WareHouseActivity.this, SMSplayful.class);
		    startActivity(intent);
    		break;
    	case 6:
    		intent.setClass(WareHouseActivity.this, SMSBsharpturn.class);
		    startActivity(intent);
    		break;
    	case 7:
    		intent.setClass(WareHouseActivity.this, SMShumorjokes.class);
		    startActivity(intent);
    		break;
    	case 8:
		    intent.setClass(WareHouseActivity.this, SMSFriendTab.class);
		    startActivity(intent);
		    break;
    	case 9:
		    intent.setClass(WareHouseActivity.this, SMSSchooljoke.class);
		    startActivity(intent);
		    break;
    	case 10:
		    intent.setClass(WareHouseActivity.this, SMSSchooljoke.class);
		    startActivity(intent);
		    break;
    	case 11:
		    intent.setClass(WareHouseActivity.this, SMSSchooljoke.class);
		    startActivity(intent);
		    break;
    	case 12:
		    intent.setClass(WareHouseActivity.this, SMSSchooljoke.class);
		    startActivity(intent);
		    break;
    	case 13:
		    intent.setClass(WareHouseActivity.this, SMSSchooljoke.class);
		    startActivity(intent);
		    break;
    	case 14:
		    intent.setClass(WareHouseActivity.this, SMSSchooljoke.class);
		    startActivity(intent);
		    break;
    	case 15:
		    intent.setClass(WareHouseActivity.this, SMSSchooljoke.class);
		    startActivity(intent);
		    break;
    	case 16:
		    intent.setClass(WareHouseActivity.this, SMSSchooljoke.class);
		    startActivity(intent);
		    break;
		    
    	}
		super.onListItemClick(l, v, position, id);
	}
	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		// TODO Auto-generated method stub
		if(keyCode==KeyEvent.KEYCODE_BACK&&event.getRepeatCount()==0){   
		    //需要处理   
			Intent intent =new Intent();
		    intent.setClass(WareHouseActivity.this, InformationActivityActivity.class);
		    startActivity(intent);
			finish();
		}   

		return false;
	}
	class backlistener implements Button.OnClickListener{
		@Override
		public void onClick(View arg0) {
			// TODO Auto-generated method stub
			Intent intent = new Intent();
			intent.setClass(WareHouseActivity.this,InformationActivityActivity.class);
			startActivity(intent);
			finish();
		}}
	class updatalistener implements Button.OnClickListener{

		@Override
		public void onClick(View v) {
			ShowListView();
		}}
}


资源截图

代码片段和文件信息

/* AUTO-GENERATED FILE.  DO NOT MODIFY.
 *
 * This class was automatically generated by the
 * aapt tool from the resource data it found.  It
 * should not be modified by hand.
 */

package cn.edu.siso;

public final class R {
    public static final class attr {
    }
    public static final class drawable {
        public static final int back=0x7f020000;
        public static final int back_lift=0x7f020001;
        public static final int background=0x7f020002;
        public static final int clean=0x7f020003;
        public static final int favorites=0x7f020004;
        public static final int help=0x7f020005;
        public static final int ic_launcher=0x7f020006;
        public static final int image=0x7f020007;
        public static final int list_driver=0x7f020

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2012-11-29 15:01  短信小窝\
     目录           0  2012-11-29 15:01  短信小窝\InformationActivity\
     文件         364  2012-04-26 15:31  短信小窝\InformationActivity\.classpath
     文件         855  2012-04-22 18:37  短信小窝\InformationActivity\.project
     文件        2735  2012-05-26 15:30  短信小窝\InformationActivity\AndroidManifest.xml
     目录           0  2012-12-04 12:41  短信小窝\InformationActivity\assets\
     目录           0  2012-11-29 15:01  短信小窝\InformationActivity\bin\
     文件     1546807  2012-07-16 09:24  短信小窝\InformationActivity\bin\InformationActivityActivity.apk
     目录           0  2012-11-29 15:01  短信小窝\InformationActivity\bin\classes\
     目录           0  2012-11-29 15:01  短信小窝\InformationActivity\bin\classes\cn\
     目录           0  2012-11-29 15:01  短信小窝\InformationActivity\bin\classes\cn\edu\
     目录           0  2012-11-29 15:01  短信小窝\InformationActivity\bin\classes\cn\edu\ContentProvide\
     文件        1065  2012-07-09 17:18  短信小窝\InformationActivity\bin\classes\cn\edu\ContentProvide\ContentActivity$backlistener.class
     文件        1700  2012-07-09 17:18  短信小窝\InformationActivity\bin\classes\cn\edu\ContentProvide\ContentActivity$sendlistener.class
     文件        3786  2012-07-09 17:18  短信小窝\InformationActivity\bin\classes\cn\edu\ContentProvide\ContentActivity.class
     文件         985  2012-07-09 17:18  短信小窝\InformationActivity\bin\classes\cn\edu\ContentProvide\Diary$DiaryColumns.class
     文件         694  2012-07-09 17:18  短信小窝\InformationActivity\bin\classes\cn\edu\ContentProvide\Diary.class
     文件        1480  2012-07-09 17:18  短信小窝\InformationActivity\bin\classes\cn\edu\ContentProvide\DiaryContentProvider$DatabaseHelper.class
     文件        5443  2012-07-09 17:18  短信小窝\InformationActivity\bin\classes\cn\edu\ContentProvide\DiaryContentProvider.class
     目录           0  2012-11-29 15:01  短信小窝\InformationActivity\bin\classes\cn\edu\Info\
     文件        1106  2012-07-09 17:18  短信小窝\InformationActivity\bin\classes\cn\edu\Info\MyInfo.class
     目录           0  2012-11-29 15:01  短信小窝\InformationActivity\bin\classes\cn\edu\MyContentHandler\
     文件        2252  2012-07-09 17:18  短信小窝\InformationActivity\bin\classes\cn\edu\MyContentHandler\MyContentHandler.class
     目录           0  2012-11-29 15:01  短信小窝\InformationActivity\bin\classes\cn\edu\siso\
     目录           0  2012-11-29 15:01  短信小窝\InformationActivity\bin\classes\cn\edu\siso\DataandAdapter\
     文件        1727  2012-07-09 17:18  短信小窝\InformationActivity\bin\classes\cn\edu\siso\DataandAdapter\DbAdapter.class
     文件        3023  2012-07-09 17:18  短信小窝\InformationActivity\bin\classes\cn\edu\siso\DataandAdapter\FavoritesManager.class
     文件       53787  2012-07-09 17:18  短信小窝\InformationActivity\bin\classes\cn\edu\siso\DataandAdapter\SmsData.class
     文件        1251  2012-07-09 17:18  短信小窝\InformationActivity\bin\classes\cn\edu\siso\EditTextActivity$Yeslisener.class
     文件         904  2012-07-09 17:18  短信小窝\InformationActivity\bin\classes\cn\edu\siso\EditTextActivity$cleanLisener.class
     文件        5544  2012-07-09 17:18  短信小窝\InformationActivity\bin\classes\cn\edu\siso\EditTextActivity.class
............此处省略194个文件信息

评论

共有 条评论