当前位置:  编程技术>移动开发
本页文章导读:
    ▪AsyncTask-实现从网络上载一张图片的功能        AsyncTask--实现从网络下载一张图片的功能 http://tech.it168.com/a2009/0907/675/000000675155_3.shtml http://blog.sina.com.cn/s/blog_62c194760100ggnu.html~type=v5_one&label=rela_nextarticle package com.android.AsynctaskTest; import java..........
    ▪ NFC相干知识与材料(一)        NFC相关知识与材料(一) 两个视频介绍关于android 手机中使用了NFC技术:[url]http://cnbeta.com/articles/132634.htm [/url]Smart Posters(转自:http://www.theregister.co.uk/2006/10/11/nfc_smart_posters/he NFC Forum has just p.........
    ▪ 应用ActivityGroup来切换Activity和Layout       使用ActivityGroup来切换Activity和Layout 前言   在一个主界面中做Activity切换一般都会用TabActivity,使用方便,Activity互相之间相对独立,但是可定制性不强,而且修改起来很麻烦。当然也可.........

[1]AsyncTask-实现从网络上载一张图片的功能
    来源: 互联网  发布时间: 2014-02-18
AsyncTask--实现从网络下载一张图片的功能

http://tech.it168.com/a2009/0907/675/000000675155_3.shtml
http://blog.sina.com.cn/s/blog_62c194760100ggnu.html~type=v5_one&label=rela_nextarticle
package com.android.AsynctaskTest;

import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;

import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.ProgressBar;

public class AsynctaskTest extends Activity {
String imageUrl = "http://hiphotos.baidu.com/baidu/pic/item/7d8aebfebf3f9e125c6008d8.jpg";
String param="";
ProgressBar mypb;
ImageView mimg;
Button btn;
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        mypb =(ProgressBar)findViewById(R.id.pgb);
        mimg =(ImageView)findViewById(R.id.wallpaper);
        btn=(Button)findViewById(R.id.btn);
        btn.setOnClickListener(new OnClickListener(){

@Override
public void onClick(View v) {
// TODO Auto-generated method stub
new myAsynctask().execute(param);
}
       
        });
       
       
    }
   
   
    Bitmap getImageFromNetwork() {
URL myFileUrl = null;
Bitmap bitmap = null;
try {
myFileUrl = new URL(/blog_article/imageUrl/index.html);
} catch (MalformedURLException e) {
e.printStackTrace();
}
try {
HttpURLConnection conn = (HttpURLConnection) myFileUrl
.openConnection();
conn.setDoInput(true);

conn.connect();
InputStream is = conn.getInputStream();

bitmap = BitmapFactory.decodeStream(is);

is.close();
} catch (IOException e) {
e.printStackTrace();
}
System.out.println(bitmap==null);
System.out.println(myFileUrl.toString());

return bitmap;
}
   
    class myAsynctask extends AsyncTask<String ,Integer  ,Bitmap >{

@Override
protected Bitmap doInBackground(String... params) {
// TODO Auto-generated method stub
Bitmap bitmap=getImageFromNetwork();
return bitmap;
}



@Override
protected void onPostExecute(Bitmap result) {
// TODO Auto-generated method stub
if(result!=null){
mimg.setImageBitmap(result);
}
else
mimg.setBackgroundResource(R.drawable.icon);
super.onPostExecute(result);
mypb.setVisibility(View.GONE);

}
@Override
protected void onProgressUpdate(Integer... values) {
// TODO Auto-generated method stub
mypb.setProgress(values[0]);
super.onProgressUpdate(values);
}

   @Override
protected void onPreExecute() {
// TODO Auto-generated method stub

mypb.setVisibility(View.VISIBLE);

mypb.setProgress(0);
super.onPreExecute();
}
   
    }
}

 

 

http://aijiawang-126-com.iteye.com/blog/592643

 


    
[2] NFC相干知识与材料(一)
    来源: 互联网  发布时间: 2014-02-18
NFC相关知识与材料(一)
两个视频介绍关于android 手机中使用了NFC技术:
[url]http://cnbeta.com/articles/132634.htm
[/url]

Smart Posters(转自:http://www.theregister.co.uk/2006/10/11/nfc_smart_posters/

he NFC Forum has just published the Smart Posters component of its short-range-radio standard, while Nokia continues with large-scale trials of the technology.

Smart Posters are signs, billboards, or any other form of advertising which will incorporate a passive (unpowered) NFC Tag, from which a user can extract data by touching it with their NFC-enabled handset. The data could be a free ringtone, a URL, or even the configuration for a local Wi-Fi hotspot.

But Smart Posters are much more important to the NFC than a mechanism for giving away a few tones or setting up networking. Smart Posters have been promoted as the mechanism by which network operators can make money out of NFC. The idea is that all those extracted URLs will generate lots of data traffic for the operator - which would be fine, except that an increasing proportion of network operators are charging a flat rate for data, so more traffic is a burden, not a profit.

Meanwhile, Nokia is running yet more trials to show how great NFC is. This time it's public transport in Tampere, Finland, in conjunction with TeliaSonera and TietoEnator. We have to assume that Nokia has an awful lot of NFC-equipped 3220s lying around the place, as it doesn't seem to have bothered to equip any more up-to-date handsets with the technology and this trial, as so many others, will be using the three year old phone.

With the Smart Poster specification completed, Nokia and its friends desperately need to prove that NFC can make money for network operators, who will be expected to subsidise handsets sporting the technology, but reducing bus queues in Tampere is not going to achieve that.

    
[3] 应用ActivityGroup来切换Activity和Layout
    来源: 互联网  发布时间: 2014-02-18
使用ActivityGroup来切换Activity和Layout
前言

   在一个主界面中做Activity切换一般都会用TabActivity,使用方便,Activity互相之间相对独立,但是可定制性不强,而且修改起来很麻烦。当然也可以把layout分开,把逻辑代码全写在主界面的逻辑代码中,但是很明显可维护性相当差,这里通过ActivityGroup来解决这个问题。



要求点击底部不同图片按钮切换不同的Activity,并在中间显示Activity对应的ContentView

二、 实现代码


    2.1  layout.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent" android:orientation="vertical"
    android:layout_height="fill_parent">
    <LinearLayout android:gravity="center_horizontal"
        android:background="@drawable/myinfor2" android:layout_width="fill_parent"
        android:layout_height="wrap_content">
        <TextView android:id="@+id/cust_title" android:textColor="@android:color/white"
            android:textSize="28sp" android:text="模块1" android:layout_width="wrap_content"
            android:layout_height="wrap_content"></TextView>
    </LinearLayout>
    <!-- 中间动态加载View -->
    <ScrollView android:measureAllChildren="true" android:id="@+id/containerBody"
        android:layout_weight="1" android:layout_height="fill_parent"
        android:layout_width="fill_parent">
    </ScrollView>
    <LinearLayout android:background="@android:color/black"
        android:layout_gravity="bottom" android:orientation="horizontal"
        android:layout_width="fill_parent" android:layout_height="wrap_content">
        <!-- 功能模块按钮1 -->
        <ImageView android:id="@+id/btnModule1" android:src="/blog_article/@android_drawable/ic_dialog_dialer/index.html"
            android:layout_marginLeft="7dp" android:layout_marginTop="3dp"
            android:layout_marginBottom="3dp" android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
        <!-- 功能模块按钮2 -->
        <ImageView android:id="@+id/btnModule2" android:src="/blog_article/@android_drawable/ic_dialog_info/index.html"
            android:layout_marginLeft="7dp" android:layout_marginTop="3dp"
            android:layout_marginBottom="3dp" android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
        <!-- 功能模块按钮3 -->
        <ImageView android:id="@+id/btnModule3" android:src="/blog_article/@android_drawable/ic_dialog_alert/index.html"
            android:layout_marginLeft="7dp" android:layout_marginTop="3dp"
            android:layout_marginBottom="3dp" android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
    </LinearLayout>
</LinearLayout>


 2.2  TestView.java
/**
 * 使用ActivityGroup来切换Activity和Layout
 * @author 农民伯伯
 * @version 2010-9-7
 * 
 */
public class TestView extends ActivityGroup {

    private ScrollView container = null;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // 隐藏标题栏
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        // 设置视图
        setContentView(R.layout.layout);

        container = (ScrollView) findViewById(R.id.containerBody);

        // 模块1
        ImageView btnModule1 = (ImageView) findViewById(R.id.btnModule1);
        btnModule1.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                container.removeAllViews();
                container.addView(getLocalActivityManager().startActivity(
                        "Module1",
                        new Intent(TestView.this, ModuleView1.class)
                                .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP))
                        .getDecorView());
            }
        });

        // 模块2
        ImageView btnModule2 = (ImageView) findViewById(R.id.btnModule2);
        btnModule2.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                container.removeAllViews();
                container.addView(getLocalActivityManager().startActivity(
                        "Module2",
                        new Intent(TestView.this, ModuleView2.class)
                                .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP))
                        .getDecorView());
            }
        });

        // 模块3
        ImageView btnModule3 = (ImageView) findViewById(R.id.btnModule3);
        btnModule3.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                container.removeAllViews();
                container.addView(getLocalActivityManager().startActivity(
                        "Module3",
                        new Intent(TestView.this, ModuleView3.class)
                                .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP))
                        .getDecorView());
            }
        });
    }
}





    
最新技术文章:
▪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提高之MediaPlayer播放网络视频的实现方法... iis7站长之家
▪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