-
获取系统图库的图片,调用系统相机,并生成预览,
** * 这个是进入相册显示所有图片的界面 * * @author king * @QQ:595163260 * @version 2014年10月18日 下午11:47:15 */public class AlbumActivity extends Activity {//显示手机里的所有图片的列表控件private GridView gridView;//当手机里没有图片时,提示用户没有图片的控件private TextView tv;//gridView的adapterprivate AlbumGridViewAdapter gridImageAdapter;//完成按钮private Button okButton;// 返回按钮private Button back;// 取消按钮private Button cancel;private Intent intent;// 预览按钮private Button preview;private Context mContext;private ArrayList dataList;private AlbumHelper helper;public static List contentList;public static Bitmap bitmap;protected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(Res.getLayoutID("plugin_camera_album"));PublicWay.activityList.add(this);mContext = this;//注册一个广播,这个广播主要是用于在GalleryActivity进行预览时,防止当所有图片都删除完后,再回到该页面时被取消选中的图片仍处于选中状态IntentFilter filter = new IntentFilter("data.broadcast.action"); registerReceiver(broadcastReceiver, filter); bitmap = BitmapFactory.decodeResource(getResources(),Res.getDrawableID("plugin_camera_no_pictures")); init();initListener();//这个函数主要用来控制预览和完成按钮的状态isShowOkBt();}BroadcastReceiver broadcastReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { //mContext.unregisterReceiver(this); // TODO Auto-generated method stub gridImageAdapter.notifyDataSetChanged(); } }; // 预览按钮的监听private class PreviewListener implements OnClickListener {public void onClick(View v) {if (Bimp.tempSelectBitmap.size() > 0) {intent.putExtra("position", "1");intent.setClass(AlbumActivity.this, GalleryActivity.class);startActivity(intent);}}}// 完成按钮的监听private class AlbumSendListener implements OnClickListener {public void onClick(View v) {overridePendingTransition(R.anim.activity_translate_in, R.anim.activity_translate_out);intent.setClass(mContext, MainActivity.class);startActivity(intent);finish();}}// 返回按钮监听private class BackListener implements OnClickListener {public void onClick(View v) {intent.setClass(AlbumActivity.this, ImageFile.class);startActivity(intent);}}// 取消按钮的监听private class CancelListener implements OnClickListener {public void onClick(View v) {Bimp.tempSelectBitmap.clear();intent.setClass(mContext, MainActivity.class);startActivity(intent);}}// 初始化,给一些对象赋值private void init() {helper = AlbumHelper.getHelper();helper.init(getApplicationContext());contentList = helper.getImagesBucketList(false);dataList = new ArrayList();for(int i = 0; i= PublicWay.num) {toggleButton.setChecked(false);chooseBt.setVisibility(View.GONE);if (!removeOneData(dataList.get(position))) {Toast.makeText(AlbumActivity.this, Res.getString("only_choose_num"),200).show();}return;}if (isChecked) {chooseBt.setVisibility(View.VISIBLE);Bimp.tempSelectBitmap.add(dataList.get(position));okButton.setText(Res.getString("finish") "(" Bimp.tempSelectBitmap.size() "/" PublicWay.num ")");} else {Bimp.tempSelectBitmap.remove(dataList.get(position));chooseBt.setVisibility(View.GONE);okButton.setText(Res.getString("finish") "(" Bimp.tempSelectBitmap.size() "/" PublicWay.num ")");}isShowOkBt();}});okButton.setOnClickListener(new AlbumSendListener());}private boolean removeOneData(ImageItem imageItem) {if (Bimp.tempSelectBitmap.contains(imageItem)) {Bimp.tempSelectBitmap.remove(imageItem);okButton.setText(Res.getString("finish") "(" Bimp.tempSelectBitmap.size() "/" PublicWay.num ")");return true;}return false;}public void isShowOkBt() {if (Bimp.tempSelectBitmap.size() > 0) {okButton.setText(Res.getString("finish") "(" Bimp.tempSelectBitmap.size() "/" PublicWay.num ")");preview.setPressed(true);okButton.setPressed(true);preview.setClickable(true);okButton.setClickable(true);okButton.setTextColor(Color.WHITE);preview.setTextColor(Color.WHITE);} else {okButton.setText(Res.getString("finish") "(" Bimp.tempSelectBitmap.size() "/" PublicWay.num ")");preview.setPressed(false);preview.setClickable(false);okButton.setPressed(false);okButton.setClickable(false);okButton.setTextColor(Color.parseColor("#E1E0DE"));preview.setTextColor(Color.parseColor("#E1E0DE"));}}public boolean onKeyDown(int keyCode, KeyEvent event) {if (keyCode == KeyEvent.KEYCODE_BACK) {intent.setClass(AlbumActivity.this, ImageFile.class);startActivity(intent);}return false;}@Overrideprotected void onRestart() {isShowOkBt();super.onRestart();}
- 2014-12-10下载
- 积分:1
-
java实现文件分割与合并 类示例源码
java实现文件分割与合并 类示例源码
- 2015-01-14下载
- 积分:1
-
android Sax解析实例源码下载
android Sax解析实例源码下载
- 2014-03-14下载
- 积分:1
-
android 音乐播放器显示歌词源码(天天动听悬浮歌词)
android 音乐播放器显示歌词源码(天天动听悬浮歌词)
- 2014-05-23下载
- 积分:1
-
android 滑动删除例子源码下载
android 滑动删除例子源码下载
- 2015-04-22下载
- 积分:1
-
android 播放网络MP3 音乐播放
简单的基本功能,实测可行。 核心代码:package com.sharpandroid.music.activity;import java.io.IOException;import android.app.Activity;import android.os.Bundle;import android.util.Log;import android.view.View;import android.widget.Button;import android.widget.ImageButton;import android.widget.SeekBar;import android.widget.TextView;import com.sharpandroid.music.R;import com.sharpandroid.music.StreamingMediaPlayer;public class MediaPlayer extends Activity { private Button streamButton; private ImageButton playButton; private boolean isPlaying; private TextView playTime; private StreamingMediaPlayer audioStreamer; @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.main); initControls(); } private void initControls() { playTime=(TextView) findViewById(R.id.playTime); streamButton = (Button) findViewById(R.id.button_stream); streamButton.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { startStreamingAudio(); }}); playButton = (ImageButton) findViewById(R.id.button_play); playButton.setEnabled(false); playButton.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { if (audioStreamer.getMediaPlayer().isPlaying()) { audioStreamer.getMediaPlayer().pause(); playButton.setImageResource(R.drawable.button_play); } else { audioStreamer.getMediaPlayer().start(); audioStreamer.startPlayProgressUpdater(); playButton.setImageResource(R.drawable.button_pause); } isPlaying = !isPlaying; }}); } private void startStreamingAudio() { try { final SeekBar progressBar = (SeekBar) findViewById(R.id.progress_bar); if ( audioStreamer != null) { audioStreamer.interrupt(); } audioStreamer = new StreamingMediaPlayer(this, playButton, streamButton, progressBar,playTime); audioStreamer.startStreaming("http://192.168.64.1/xa.mp3",5208, 216); streamButton.setEnabled(false); } catch (IOException e) { Log.e(getClass().getName(), "读取音乐出错!", e); } }}
- 2014-05-26下载
- 积分:1
-
用于记录女生生理期,以便女生自我保护
界面均为自己绘图画出来的,可以参看学习一下绘图基本方法
- 2015-04-02下载
- 积分:1
-
视频聊天android端代码 下载
使用webrtc的开源android端代码
- 2015-05-27下载
- 积分:1
-
android 百度地图api 示例源码
android 百度地图api 示例源码
- 2014-02-25下载
- 积分:1
-
批量替换 android反编译之后 R.java文件中的数字(id对应的值) 实例源码下载
好多人反编译都遇到 反编译出来的 R.id.... 这些都变成了数字,这个程序就是批量替换这些数字为可读性更好的id,支持 UTF-8 GBK gb2312 ,没乱码,亲测通过
- 2014-05-26下载
- 积分:1