当前位置:  编程技术>移动开发
本页文章导读:
    ▪GridView的分页滑动展示实现跳转Activity        GridView的分页滑动显示实现跳转Activity 首先定义一个实现GridView显示的图片页面,将所有要跳转的图片分成三页显示   MainManagerActivity package com.hwtt.android.sellmanager.ui; import java.util.ArrayList; impor.........
    ▪ 图片转base64串及反折回图片        图片转base64串及反转回图片 图片转base64串:     UIImage *_originImage = [UIImage imageNamed:@"full_playlist_hl.png"];     NSData *_data = UIImageJPEGRepresentation(_image, 1.0f);     NSString *_encodedImageStr = [_data base64Enco.........
    ▪ 上传打包时被拒, udid有关问题导致(如果有第三方包请替换最新第三方的包)       上传打包时被拒, udid问题导致(如果有第三方包请替换最新第三方的包) 今天在打包完上传到苹果审核的时候,被拒了。以下是被拒信息 Apps are not permitted to access the UDID and must not use the uniq.........

[1]GridView的分页滑动展示实现跳转Activity
    来源: 互联网  发布时间: 2014-02-18
GridView的分页滑动显示实现跳转Activity

首先定义一个实现GridView显示的图片页面,将所有要跳转的图片分成三页显示

 

MainManagerActivity

package com.hwtt.android.sellmanager.ui;

import java.util.ArrayList;
import java.util.List;

import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;

import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.content.Context;
import android.content.DialogInterface;

import android.content.Intent;
import android.content.SharedPreferences;
import android.location.LocationManager;
import android.os.Bundle;
import android.provider.Settings;
import android.support.v4.view.ViewPager;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.GridView;

import com.hwtt.android.sellmanager.adapter.MainGridViewAdapter;
import com.hwtt.android.sellmanager.adapter.MainPagerAdapter;
import com.hwtt.android.sellmanager.bean.ItemInfo;
import com.hwtt.android.sellmanager.utils.HttpUtil;

public class MainManagerActivity extends BaseReceiverActivity {
	private SharedPreferences sp1;
	GridView gridView;
	ViewPager pager;
	Context context = MainManagerActivity.this;
	MainPagerAdapter adapter;
	Class<?> mActivities1[] = { AttendanceManagerActivity.class,
			GoodsSalesManagerActivity.class, GoodsManagerActivity.class,
			TaskManagerActivity.class, NoticeActivity.class,
			PepoleManagerActivity.class };
	Class<?> mActivities2[] = { CustomerActivity.class,
			SystemSetActivity.class, InquireActivity.class,
			NetWorkActivity.class, MessageActivity.class,
			AddressBookActivity.class };
	Class<?> mActivities3[] = { ContactActivity.class,SMSMessageActivity.class };

	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		// requestWindowFeature(Window.FEATURE_NO_TITLE);

		
		setContentView(R.layout.sellmainpage);
		sp1 = this
				.getSharedPreferences("userInfo", Context.MODE_WORLD_READABLE);
		init();
	}

	@Override
	protected void onActivityResult(int requestCode, int resultCode, Intent data) {
		super.onActivityResult(requestCode, resultCode, data);
		pager.setCurrentItem(requestCode);

	}

	void init() {
		pager = (ViewPager) findViewById(R.id.vPager);
		ArrayList<View> list = new ArrayList<View>();
		LayoutInflater layout = getLayoutInflater();
		View view1 = layout.inflate(R.layout.lay1, null);
		View view2 = layout.inflate(R.layout.lay2, null);
		View view3 = layout.inflate(R.layout.lay3, null);
		GridView gridview1 = (GridView) view1.findViewById(R.id.lay1_grid_view);
		GridView gridview2 = (GridView) view2.findViewById(R.id.lay2_grid_view);
		GridView gridview3 = (GridView) view3.findViewById(R.id.lay3_grid_view);
		MainGridViewAdapter gridAdapter1 = new MainGridViewAdapter(getList(1),
				context);
		MainGridViewAdapter gridAdapter2 = new MainGridViewAdapter(getList(2),
				context);
		MainGridViewAdapter gridAdapter3 = new MainGridViewAdapter(getList(3),
				context);
		gridview1.setAdapter(gridAdapter1);
		gridview2.setAdapter(gridAdapter2);
		gridview3.setAdapter(gridAdapter3);
		list.add(view1);
		list.add(view2);
		list.add(view3);
		MainPagerAdapter adapter = new MainPagerAdapter(list);
		pager.setAdapter(adapter);
	 gridview1.setOnItemClickListener(new OnItemClickListener() {
			@Override
			public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
					long arg3) {
				onListItemClick(arg2, 1);
			}
		});
		gridview2.setOnItemClickListener(new OnItemClickListener() {
			@Override
			public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
					long arg3) {
				onListItemClick(arg2, 2);
			}
		});
		gridview3.setOnItemClickListener(new OnItemClickListener() {
			@Override
			public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
					long arg3) {
				onListItemClick(arg2, 3);
			}
		});
	}

	void onListItemClick(int index, int page) {
		if (page == 1) {
			if (index < 0 || index >= mActivities1.length)
				return;
			Intent intent = new Intent(context, mActivities1[index]);
			startActivityForResult(intent, page - 1);

			// this.startActivity(intent);
		} else if (page == 2) {
			if (index < 0 || index >= mActivities2.length)
				return;
			Intent intent = new Intent(context, mActivities2[index]);
			startActivityForResult(intent, page - 1);
		} else {
			if (index < 0 || index >= mActivities3.length) {
				return;
			} else if (index == 0) {
				Intent intent = new Intent(context, mActivities3[index]);
				startActivityForResult(intent, page - 1);
			} else if (index == 1) {
				Intent intent = new Intent(Intent.ACTION_VIEW);
				intent.putExtra("address", " ");
				intent.putExtra("sms_body", " ");
				intent.setType("vnd.android-dir/mms-sms");
				startActivity(intent);
			}
		}
		int version = Integer.valueOf(android.os.Build.VERSION.SDK);
		if (version >= 5) {
			overridePendingTransition(R.anim.fade, R.anim.hold);
			//滑动分页的形式
			// overridePendingTransition(R.anim.alpha_rotate,
			// R.anim.my_alpha_action);
			// overridePendingTransition(R.anim.alpha_scale_rotate,
			// R.anim.my_alpha_action);
			// overridePendingTransition(
			// R.anim.alpha_scale_translate_rotate,
			// R.anim.my_alpha_action);
			// overridePendingTransition(R.anim.alpha_scale_translate,
			// R.anim.my_alpha_action);
			// overridePendingTransition(R.anim.alpha_scale,
			// R.anim.my_alpha_action);
			// overridePendingTransition(R.anim.alpha_translate_rotate,
			// R.anim.my_alpha_action);
			// overridePendingTransition(R.anim.alpha_translate,
			// R.anim.my_alpha_action);
			// overridePendingTransition(R.anim.my_rotate_action,
			// R.anim.my_alpha_action);
			// overridePendingTransition(R.anim.my_scale_action,
			// R.anim.my_alpha_action);
			// overridePendingTransition(R.anim.my_translate_action,
			// R.anim.my_alpha_action);
			// overridePendingTransition(R.anim.myanimation_simple,
			// R.anim.my_alpha_action);
			// overridePendingTransition(R.anim.myown_design,
			// R.anim.my_alpha_action);
			// overridePendingTransition(R.anim.scale_rotate,
			// R.anim.my_alpha_action);
			// overridePendingTransition(R.anim.scale_translate_rotate,
			// R.anim.my_alpha_action);
			// overridePendingTransition(R.anim.scale_translate,
			// R.anim.my_alpha_action);
			// overridePendingTransition(R.anim.translate_rotate,
			// R.anim.my_alpha_action);
			// overridePendingTransition(R.anim.hyperspace_in,
			// R.anim.hyperspace_out);
			// overridePendingTransition(R.anim.shake,
			// R.anim.my_alpha_action);
			// overridePendingTransition(R.anim.push_left_in,
			// R.anim.push_left_out);
			// overridePendingTransition(R.anim.push_up_in,
			// R.anim.push_up_out);
			// overridePendingTransition(R.anim.slide_left,
			// R.anim.slide_right);
			// overridePendingTransition(R.anim.slide_top_to_bottom,
			// R.anim.my_alpha_action);
			// overridePendingTransition(R.anim.wave_scale,
			// R.anim.my_alpha_action);
		}
	}

	protected void onStart() {
		super.onStart();

	}

	protected void dialog() {
		AlertDialog.Builder builder = new Builder(context);
		builder.setMessage("确定要退出吗?");
		builder.setTitle("提示");
		builder.setPositiveButton("确认",
				new android.content.DialogInterface.OnClickListener() {
					public void onClick(DialogInterface dialog, int which) {
						dialog.dismiss();
						// update zongshiwei close all activity by
						// broadcastReceiver
						myExit();
						// finish();
						String path =getResources().getString(R.string.exitPPTUrl);
						List<NameValuePair> list = new ArrayList<NameValuePair>();

						NameValuePair value1 = new BasicNameValuePair(
								"username", sp1.getString("USER_NAME", ""));

						list.add(value1);
						HttpUtil httpUtil = new HttpUtil();

						String result = httpUtil.getMsgFromServer(path, list);
					}
				});
		builder.setNegativeButton("取消",
				new android.content.DialogInterface.OnClickListener() {
					public void onClick(DialogInterface dialog, int which) {
						dialog.dismiss();
					}
				});
		builder.create().show();
	}

	protected void myExit() {
		Intent intent = new Intent();
		intent.setAction("ExitApp");
		this.sendBroadcast(intent);
		super.finish();
	}

	public boolean onKeyDown(int keyCode, android.view.KeyEvent event) {
		if (KeyEvent.KEYCODE_BACK == keyCode && event.getRepeatCount() == 0)
			dialog();
		return true;
	};

	ArrayList<ItemInfo> getList(int i) {
		ArrayList<ItemInfo> list1 = new ArrayList<ItemInfo>();
		ArrayList<ItemInfo> list2 = new ArrayList<ItemInfo>();
		ArrayList<ItemInfo> list3 = new ArrayList<ItemInfo>();
		ItemInfo info1 = new ItemInfo();
		info1.setItem_img(R.drawable.advancedance_icon);
		info1.setItem_name("考勤管理");
		ItemInfo info2 = new ItemInfo();
		info2.setItem_img(R.drawable.sale_manager);
		info2.setItem_name("销量管理");
		ItemInfo info3 = new ItemInfo();
		info3.setItem_img(R.drawable.goods_mana);
		info3.setItem_name("货品管理");
		ItemInfo info4 = new ItemInfo();
		info4.setItem_img(R.drawable.task_mana);
		info4.setItem_name("任务管理");
		ItemInfo info5 = new ItemInfo();
		info5.setItem_img(R.drawable.ico_msg_notice);
		info5.setItem_name("通知公告");
		ItemInfo info6 = new ItemInfo();
		info6.setItem_img(R.drawable.pepole_locat);
		info6.setItem_name("人员管理");
		ItemInfo info7 = new ItemInfo();
		info7.setItem_img(R.drawable.kehuguanli);
		info7.setItem_name("客户管理");
		ItemInfo info8 = new ItemInfo();
		info8.setItem_img(R.drawable.systemset);
		info8.setItem_name("系统设置");
		ItemInfo info9 = new ItemInfo();
		info9.setItem_img(R.drawable.cru);
		info9.setItem_name("查询统计");
		ItemInfo info10 = new ItemInfo();
		info10.setItem_img(R.drawable.network_manage);
		info10.setItem_name("网点巡视");
		ItemInfo info11 = new ItemInfo();
		info11.setItem_img(R.drawable.upload_message);
		info11.setItem_name("信息上报");
		ItemInfo info12 = new ItemInfo();
		info12.setItem_img(R.drawable.address_book);
		info12.setItem_name("公司通讯录");
		ItemInfo info13 = new ItemInfo();
		info13.setItem_img(R.drawable.call);
		info13.setItem_name("多人会话");
		ItemInfo info14 = new ItemInfo();
		info14.setItem_img(R.drawable.sms);
		info14.setItem_name("短信群发");
		list1.add(info1);
		list1.add(info2);
		list1.add(info3);
		list1.add(info4);
		list1.add(info5);
		list1.add(info6);
		list2.add(info7);
		list2.add(info8);
		list2.add(info9);
		list2.add(info10);
		list2.add(info11);
		list2.add(info12);
		list3.add(info13);
		list3.add(info14);
		if (i == 1)
			return list1;
		else if (i == 2)
			return list2;
		else
			return list3;
	}

}

 

定义填充页面的图片跟图片下边的文字MainGridViewAdapter

 

 

package com.hwtt.android.sellmanager.adapter;

import java.util.ArrayList;

import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.hwtt.android.sellmanager.bean.ItemInfo;
import com.hwtt.android.sellmanager.ui.R;

public class MainGridViewAdapter extends BaseAdapter {
	ArrayList<ItemInfo> list;
	Context context;
 
	public MainGridViewAdapter(ArrayList<ItemInfo> list,Context context)
	{
		this.list=list;
		this.context=context;
	}
	public int getCount() {
		// TODO Auto-generated method stub
		return list.size();
	}

	@Override
	public Object getItem(int position) {
		return list.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		if(convertView==null)
		{
			LayoutInflater layout=LayoutInflater.from(context);
			convertView=layout.inflate(R.layout.main_page_item, null);
		}
		ImageView itemImg=(ImageView)convertView.findViewById(R.id.item_img);
		TextView itemName=(TextView)convertView.findViewById(R.id.item_tv);
		itemImg.setImageResource(list.get(position).getItem_img());
		itemName.setText(list.get(position).getItem_name());
		return convertView;
	}
}

 

然后定义分页的MainPagerAdapter

 

package com.hwtt.android.sellmanager.adapter;

import java.util.ArrayList;

import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Parcelable;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.widget.Button;

import com.hwtt.android.sellmanager.ui.R;

public class MainPagerAdapter extends PagerAdapter{

	ArrayList<View> list;
	public MainPagerAdapter (ArrayList<View> list) 
	{
		this.list=list;
	}
	public void destroyItem(View arg0, int arg1, Object arg2) {
		((ViewPager) arg0).removeView(list.get(arg1));
	}

	@Override
	public void finishUpdate(View arg0) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public int getCount() {
		return list.size();
	}

	@Override
	public Object instantiateItem(View arg0, int arg1) {
		((ViewPager) arg0).addView(list.get(arg1),0);
		return list.get(arg1);
	}

	@Override
	public boolean isViewFromObject(View arg0, Object arg1) {
		// TODO Auto-generated method stub
		return  arg0==(arg1);
	}

	@Override
	public void restoreState(Parcelable arg0, ClassLoader arg1) {
		
	}

	@Override
	public Parcelable saveState() {
		return null;
	}

	@Override
	public void startUpdate(View arg0) {
		
	}

	
}

 

然后定义填充图片与文字的XML     main_page_item

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical"
    >
<ImageView android:id="@+id/item_img"
    android:layout_width="80dp"
    android:layout_height="70dp"
    android:layout_marginTop="15dp"
    android:layout_marginLeft="30dp"
    android:layout_marginRight="30dp"
    android:scaleType="fitXY"/>
<TextView android:id="@+id/item_tv"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@id/item_img"
    android:maxLines="2"
    android:layout_alignLeft="@id/item_img"
    android:layout_alignRight="@id/item_img"
    android:gravity="center_horizontal"
    android:textSize="13sp"
    android:textColor="#000000"
   />
</RelativeLayout>

 还有就是显示GridView的布局   sellmainpage

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical"
    
     >
       <TextView 
           android:id="@+id/main_tv_hint"
        android:layout_width="fill_parent"
        android:layout_height="50dp"
        android:textColor="#000000"
        android:gravity="center"
        android:layout_marginTop="30dp"
        android:textSize="25sp"
        android:text="移动销售管家"/>
       <TextView android:id="@+id/weather_tv"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:layout_alignParentRight="true"/>
         <android.support.v4.view.ViewPager
        android:id="@+id/vPager"
        android:layout_width="wrap_content"
        android:layout_height="fill_parent"
        android:layout_below="@id/main_tv_hint"
        android:layout_gravity="center"
        android:layout_weight="1.0"
         
        android:flipInterval="30"
        android:persistentDrawingCache="animation" />
 <!--  <GridView
        android:id="@+id/main_manager_grid_view"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:columnWidth="90dp"
        android:gravity="center"
        android:horizontalSpacing="10dip"
        android:layout_margin="15dip"
        android:layout_marginTop="60dp"
        android:numColumns="3"
        android:verticalSpacing="20dip" /> -->
</RelativeLayout>

 

最后定义一个填充GridView图片与文字的一个bean  ItemInfo.java

package com.hwtt.android.sellmanager.bean;

public class ItemInfo {

	int item_img;
	String item_name;
	public int getItem_img() {
		return item_img;
	}
	public void setItem_img(int item_img) {
		this.item_img = item_img;
	}
	public String getItem_name() {
		return item_name;
	}
	public void setItem_name(String item_name) {
		this.item_name = item_name;
	}
	
}
  

 

 


    
[2] 图片转base64串及反折回图片
    来源: 互联网  发布时间: 2014-02-18
图片转base64串及反转回图片

图片转base64串:

    UIImage *_originImage = [UIImage imageNamed:@"full_playlist_hl.png"];

    NSData *_data = UIImageJPEGRepresentation(_image, 1.0f);

    NSString *_encodedImageStr = [_data base64Encoding];

 

    NSLog(@"===Encoded image:\n%@", _encodedImageStr);

 

Base64串转图片:

    NSData *_decodedImageData   = [[NSData alloc] initWithBase64Encoding:_encodedImageStr];

    UIImage *_decodedImage      = [UIImage imageWithData:_decodedImageData];

 

    NSLog(@"===Decoded image size: %@", NSStringFromCGSize(_decodedImage.size));


    
[3] 上传打包时被拒, udid有关问题导致(如果有第三方包请替换最新第三方的包)
    来源: 互联网  发布时间: 2014-02-18
上传打包时被拒, udid问题导致(如果有第三方包请替换最新第三方的包)

今天在打包完上传到苹果审核的时候,被拒了。以下是被拒信息

Apps are not permitted to access the UDID and must

not use the uniqueIdentifier method of UIDevice.

Please update your apps and servers to associate

users with the Vendor or Advertising identifiers introduced in iOS 6.

于是就搜了一下UDID,uniqueIdentifier关键字,发现并没有被调用。

这时候就比较郁闷了,都没调用怎么会导致这个问题,于是便排查了一番,猜想有可能是第三方库调用了类似方法。。。。

一个是百度的库,一个是魔方的库。。。都依次去下了最新的,重新导入。

验证之后发现还真解决了。ok,问题搞定~


    
最新技术文章:
▪Android开发之登录验证实例教程
▪Android开发之注册登录方法示例
▪Android获取手机SIM卡运营商信息的方法
▪Android实现将已发送的短信写入短信数据库的...
▪Android发送短信功能代码
▪Android根据电话号码获得联系人头像实例代码
▪Android中GPS定位的用法实例
▪Android实现退出时关闭所有Activity的方法
▪Android实现文件的分割和组装
▪Android录音应用实例教程
▪Android双击返回键退出程序的实现方法
▪Android实现侦听电池状态显示、电量及充电动...
▪Android获取当前已连接的wifi信号强度的方法
▪Android实现动态显示或隐藏密码输入框的内容
▪根据USER-AGENT判断手机类型并跳转到相应的app...
▪Android Touch事件分发过程详解
▪Android中实现为TextView添加多个可点击的文本
▪Android程序设计之AIDL实例详解
▪Android显式启动与隐式启动Activity的区别介绍
▪Android按钮单击事件的四种常用写法总结
▪Android消息处理机制Looper和Handler详解
▪Android实现Back功能代码片段总结
▪Android实用的代码片段 常用代码总结
▪Android实现弹出键盘的方法
▪Android中通过view方式获取当前Activity的屏幕截...
▪Android提高之自定义Menu(TabMenu)实现方法
▪Android提高之多方向抽屉实现方法
▪Android提高之MediaPlayer播放网络音频的实现方法...
▪Android提高之MediaPlayer播放网络视频的实现方法...
▪Android提高之手游转电视游戏的模拟操控
 


站内导航:


特别声明:169IT网站部分信息来自互联网,如果侵犯您的权利,请及时告知,本站将立即删除!

©2012-2021,,E-mail:www_#163.com(请将#改为@)

浙ICP备11055608号-3