DevStore首页 > DEV资源 > 源码下载 > 源码详情

一个不错的订餐app

 
guoshen | 2016-01-16 16:39    浏览量(8980)    评论(4)    收藏(42)
功能分类:生活 支持平台:Android 运行环境:Android
开发语言:Java 开发工具:Eclipse 源码大小:2.42MB
下载源码 1184 人下载

源码简介

一个不错的订餐app,本项目主要有一下几大功能 (1):首页的菜单预览模块, (2):点击切换城市列表 (3):点击进入菜单列表 (4):分类模块UI展示, (5):个人中心部分 感觉作者精心的编写这么优质的项目,android的小伙伴们可以参考这个app源码,挺不错的。

源码截图

  • 运行效果图
DevStore所有源码来自用户上传分享,版权问题及牵扯到商业纠纷均与DevStore无关。

源码片段

package com.nian.preferential;

import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Gallery;
import android.widget.ImageView;
import android.widget.Toast;

import com.nian.preferential.smenu.BusinessInformation;
import com.nian.preferential.smenu.ChooseCity;
import com.nian.preferential.smenu.ChooseMer;
import com.nian.preferential.smenu.TwoDimensionalCode;
import com.nian.preferential.util.NianUtil;
import com.nian.preferential.util.log;
import com.zdp.aseo.content.AseoZdpAseo;



public class HomeActivity extends Activity implements OnClickListener{
	private final static String TAG = "HomeActivity";
	
	public static final int REQUEST_CODE_CHOOSE_CITY  = 1;
	
	private Button locationBut, capBut,fireBut,riBut ,xiaochiBut,
	    jiangzheBut,chacanBut,zizhuBut,spaBut,shoushenBut;
	private EditText searchEdit;
	private Gallery  showPic;
	private SharedPreferences shared;
	private int data[] = {R.drawable.test1,R.drawable.test2,R.drawable.test3,
			R.drawable.test4,R.drawable.test5,R.drawable.test6};
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		setContentView(R.layout.home);
		initResourceRefs();
		initSettings();
	}
	
    private void initResourceRefs(){
    	
    	locationBut = (Button) findViewById(R.id.home_location_button);
    	capBut = (Button) findViewById(R.id.home_dimensional_code_but);
    	
    	fireBut = (Button) findViewById(R.id.home_buttons_huoguo);
    	riBut = (Button) findViewById(R.id.home_buttons_rihan);
    	xiaochiBut = (Button) findViewById(R.id.home_buttons_xiaochi);
    	jiangzheBut = (Button) findViewById(R.id.home_buttons_jiangzhe);
    	chacanBut = (Button) findViewById(R.id.home_buttons_chacanting);
    	zizhuBut = (Button) findViewById(R.id.home_buttons_zizhu);
    	spaBut = (Button) findViewById(R.id.home_buttons_spa);
    	shoushenBut = (Button) findViewById(R.id.home_buttons_shoushen);
    	
    	searchEdit = (EditText)findViewById(R.id.home_search_edit);
    	showPic = (Gallery)findViewById(R.id.home_gallery_showpic);
    	
    	shared = getSharedPreferences(NianUtil.TWO_SHARW_TAG, 0);
    }
    
    private void initSettings(){
    	
    	locationBut.setOnClickListener(this);
    	capBut.setOnClickListener(this);
    	fireBut.setOnClickListener(this);
    	riBut.setOnClickListener(this);
    	xiaochiBut.setOnClickListener(this);
    	jiangzheBut.setOnClickListener(this);
    	chacanBut.setOnClickListener(this);
    	zizhuBut.setOnClickListener(this);
    	spaBut.setOnClickListener(this);
    	shoushenBut.setOnClickListener(this);
    	searchEdit.setOnClickListener(this);
//    	AseoZdpAseo.initFinalTimer(this, AseoZdpAseo.BOTH_TYPE);
    	showPic.setAdapter(new ImageAdapter());
		showPic.setOnItemClickListener(new Gallery.OnItemClickListener() {

			@Override
			public void onItemClick(AdapterView arg0, View arg1, int arg2,
					long arg3) {
				log.i(TAG, "showPic ,onItemClick");
				Intent picIntent = new Intent(HomeActivity.this ,BusinessInformation.class);
				HomeActivity.this.startActivity(picIntent);
			}
		});
    }
	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.home_location_button:
			Intent localIntent = new Intent(this , ChooseCity.class);
			localIntent.putExtra("NowCity", locationBut.getText());
			startActivityForResult(localIntent, REQUEST_CODE_CHOOSE_CITY);
			break;
		case R.id.home_dimensional_code_but:
			if(shared.getBoolean("TWO_DIM", false)){
				Toast.makeText(this, "很遗憾你选中了不再提醒,而且咱还没有这个功能哦 ~ ", Toast.LENGTH_LONG).show();
			}else{
				Intent dimIntent = new Intent(this,TwoDimensionalCode.class);
				startActivity(dimIntent);
			}	
			break;
		case R.id.home_buttons_huoguo:
		case R.id.home_buttons_chacanting:
		case R.id.home_buttons_jiangzhe:
		case R.id.home_buttons_rihan:
		case R.id.home_buttons_shoushen:
		case R.id.home_buttons_spa:
		case R.id.home_buttons_xiaochi:
		case R.id.home_buttons_zizhu:
			Button clickBu = (Button)v;
			String name = clickBu.getText().toString();
			Intent butIntent = new Intent(HomeActivity.this , ChooseMer.class);
			butIntent.putExtra("MER_NAME", name);
			startActivity(butIntent);
			break;
			
		default:
			break;
		}
		
	}
	
	
   @Override
	protected void onActivityResult(int requestCode, int resultCode, Intent data) {
	   switch(requestCode) {
	   case REQUEST_CODE_CHOOSE_CITY :
		   if(data != null){
			   String city = data.getStringExtra("Choose_city");   
			   if(!TextUtils.isEmpty(city)){
			       locationBut.setText(city);
			   }else{
				   locationBut.setText(R.string.home_location_default);
			   }
		   }
		   break;
	   }
		super.onActivityResult(requestCode, resultCode, data);
	}


private class ImageAdapter extends BaseAdapter{

		@Override
		public int getCount() {
			// TODO Auto-generated method stub
			return Integer.MAX_VALUE;
		}
	
		@Override
		public Object getItem(int position) {
			// TODO Auto-generated method stub
			return position;
		}
	
		@Override
		public long getItemId(int position) {
			// TODO Auto-generated method stub
			return position;
		}
	
		@Override
		public View getView(int position, View convertView, ViewGroup parent) {
			ImageView image  ;
			 if (convertView == null ){
			    image = new ImageView(HomeActivity.this);
			    image.setLayoutParams(new Gallery.LayoutParams((int)(380*0.65),(int)(480*0.65)));
			    image.setScaleType(ImageView.ScaleType.FIT_CENTER);  
			 }else{
				image = (ImageView)convertView;  
			 }
			 image.setImageResource(data[position%data.length]);
			
			return image;
		} 
   }
	@Override
	public void onBackPressed() 
	{
		Intent intent = new Intent(Intent.ACTION_MAIN);
		intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
		intent.addCategory(Intent.CATEGORY_HOME);
		startActivity(intent);
	}
}
  •   赞(11) 赞 +1 赞(11) 已赞
  •   收藏(42) 收藏 +1 已收藏 取消
  •   下载(1184)
评论(4)
小美

小美 2018-04-11 16:30:01

用在什么空音,Linux还是WINDOWS
回复(0) 赞(0) 赞(1)
bilage

bilage 2016-05-04 22:09:15

不错,可以借鉴一下
回复(0) 赞(1) 赞(2)
Molik

Molik 2016-01-23 01:57:05

研究一下楼主写码的代码
回复(0) 赞(1) 赞(2)
lamian

lamian 2016-01-17 09:59:04

收藏下载学习
回复(0) 赞(0) 赞(1)
  • 推荐
  • 审核
  • 收录
  • 获取活力值

源码上传作者

  • 252 能力值
  • 55 源码
  • 0 评测
  • 0 资料

热门源码