当前位置:  编程技术>移动开发
本页文章导读:
    ▪textview中文字实用其大小        textview中文字适用其大小 import android.content.Context; import android.graphics.Paint; import android.util.AttributeSet; import android.widget.TextView;  public class FontFitTextView extends TextView {      public FontFitTextView(Con.........
    ▪ Application Fundamentals-Starting tasks        Application Fundamentals--Starting tasks Starting tasksAn activity is set up as the entry point for a task by giving it an intent filter with "android.intent.action.MAIN" as the specified action and "android.intent.category.LAUNCHER" as the specif.........
    ▪ 存数模式总结       存数方式总结 http://www.eigo.co.uk/Managing-State-in-an-Android-Activity.aspx ......

[1]textview中文字实用其大小
    来源: 互联网  发布时间: 2014-02-18
textview中文字适用其大小

import android.content.Context; 
import android.graphics.Paint; 
import android.util.AttributeSet; 
import android.widget.TextView; 
 
public class FontFitTextView extends TextView { 
 
    public FontFitTextView(Context context) { 
        super(context); 
        initialise(); 
    } 
 
    public FontFitTextView(Context context, AttributeSet attrs) { 
        super(context, attrs); 
        initialise(); 
    } 
 
    private void initialise() { 
        testPaint = new Paint(); 
        testPaint.set(this.getPaint()); 
        //max size defaults to the intially specified text size unless it is too small 
        maxTextSize = this.getTextSize(); 
        if (maxTextSize < 11) { 
            maxTextSize = 20; 
        } 
        minTextSize = 10; 
    } 
 
    /* Re size the font so the specified text fits in the text box 
     * assuming the text box is the specified width. 
     */ 
    private void refitText(String text, int textWidth) {  
        if (textWidth > 0) { 
            int availableWidth = textWidth - this.getPaddingLeft() - this.getPaddingRight(); 
            float trySize = maxTextSize; 
 
            testPaint.setTextSize(trySize); 
            while ((trySize > minTextSize) && (testPaint.measureText(text) > availableWidth)) { 
                trySize -= 1; 
                if (trySize <= minTextSize) { 
                    trySize = minTextSize; 
                    break; 
                } 
                testPaint.setTextSize(trySize); 
            } 
 
            this.setTextSize(trySize); 
        } 
    } 
 
    @Override 
    protected void onTextChanged(final CharSequence text, final int start, final int before, final int after) { 
        refitText(text.toString(), this.getWidth()); 
    } 
 
    @Override 
    protected void onSizeChanged (int w, int h, int oldw, int oldh) { 
        if (w != oldw) { 
            refitText(this.getText().toString(), w); 
        } 
    } 
 
    //Getters and Setters 
    public float getMinTextSize() { 
        return minTextSize; 
    } 
 
    public void setMinTextSize(int minTextSize) { 
        this.minTextSize = minTextSize; 
    } 
 
    public float getMaxTextSize() { 
        return maxTextSize; 
    } 
 
    public void setMaxTextSize(int minTextSize) { 
        this.maxTextSize = minTextSize; 
    } 
 
    //Attributes 
    private Paint testPaint; 
    private float minTextSize; 
    private float maxTextSize; 
 


    
[2] Application Fundamentals-Starting tasks
    来源: 互联网  发布时间: 2014-02-18
Application Fundamentals--Starting tasks
Starting tasks

An activity is set up as the entry point for a task by giving it an intent filter with "android.intent.action.MAIN" as the specified action and "android.intent.category.LAUNCHER" as the specified category. (There's an example of this type of filter in the earlier Intent Filters section.) A filter of this kind causes an icon and label for the activity to be displayed in the application launcher, giving users a way both to launch the task and to return to it at any time after it has been launched.

翻译:把一个Activity设置为一个task的起点的办法是在manifest文件中的这个Activity元素的intent filter子元素的action属性设定为 "android.intent.action.MAIN" 的同时把它的category属性设定为"android.intent.category.LAUNCHER",这样设置的过滤器会使得对应的Activity在系统的应用程序发射台界面中显示一个图标和说明文字,这样一来,用户可以在系统的应用程序发射台界面中选中这个图标来启动这个task,而且用户也可以在task启动后还可以随时返回该task。

This second ability is important: Users must be able to leave a task and then come back to it later. For this reason, the two launch modes that mark activities as always initiating a task, "singleTask" and "singleInstance", should be used only when the activity has a MAIN and LAUNCHER filter. Imagine, for example, what could happen if the filter is missing: An intent launches a "singleTask" activity, initiating a new task, and the user spends some time working in that task. The user then presses the HOME key. The task is now ordered behind and obscured by the home screen. And, because it is not represented in the application launcher, the user has no way to return to it.

翻译:能使得用户可以在一个task启动后随时能返回该task的这个功能很重要:因为这个功能也是用户实际使用过程很需要的,所以,action属性是 "android.intent.action.MAIN" 和category属性是"android.intent.category.LAUNCHER"的Activity的启动模式只能是"singleTask" 或 "singleInstance"这两个启动模式。可以想象一下,假如没有设定这两个属性值的话,将会发生什么问题:一旦一个intent请求对象启动了一个"singleTask"启动模式的activity后,系统将启动一个新的task,用户基于这个task花了很长时间做了相关的操作,然后,用户按下HOME键,这时候该task退到后台,从主屏幕中消失,由于该Activity没有同时设定它的过滤器元素的action属性设定为 "android.intent.action.MAIN" 、category属性设定为"android.intent.category.LAUNCHER",所以在应用发射台上是没有相应的启动图标的,那么就直接导致用户无法重新回到该task。

A similar difficulty attends the FLAG_ACTIVITY_NEW_TASK flag. If this flag causes an activity to begin a new task and the user presses the HOME key to leave it, there must be some way for the user to navigate back to it again. Some entities (such as the notification manager) always start activities in an external task, never as part of their own, so they always put FLAG_ACTIVITY_NEW_TASK in the intents they pass to startActivity(). If you have an activity that can be invoked by an external entity that might use this flag, take care that the user has a independent way to get back to the task that's started.

翻译:同样的问题也会在使用FLAG_ACTIVITY_NEW_TASK flag的时候遇到,如果一个intent的这个flag导致Activity启动一个新的task,然后用户按下HOME键离开当前task,必须能让用户还能返回该task。有些实体如notification manager通常是以外部task方式启动Activity的,这些实体总是先在一个intent中设定FLAG_ACTIVITY_NEW_TASK,然后执行startActivity()方法启动某个Activity。如果你的Activity也是这样的方式被实体调用并启动的话,需要特别注意你的应用需要提供其他的途径能让用户能够重新返回到这个task。

For those cases where you don't want the user to be able to return to an activity, set the <activity> element's finishOnTaskLaunch to "true". See Clearing the stack, earlier.

翻译:某些场合你可能不希望用户返回到task堆栈中的某个Activity对应的界面,那么可以把这个Activity的启动模式finishOnTaskLaunch 设定为 "true",具体请查阅之前的章节:Clearing the stack

    
[3] 存数模式总结
    来源: 互联网  发布时间: 2014-02-18
存数方式总结

http://www.eigo.co.uk/Managing-State-in-an-Android-Activity.aspx


    
最新技术文章:
▪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