当前位置:  编程技术>移动开发
本页文章导读:
    ▪[新闻资讯] [业界动态] 一个轻量级的强大的组件库-as搬动开发者        [新闻资讯] [业界动态] 一个轻量级的强大的组件库--as移动开发者 资讯类型: 翻译来源页面: http://madskool.wordpress.com/2011/05/11/using-madcomponents-with-minimalcomps-or-flobile-libraries/资讯原标题: Using MadC.........
    ▪ UIPickerView控件中自定义展示的字体大小及样式        UIPickerView控件中自定义显示的字体大小及样式 通过覆盖如下方法实现 - (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view{ UILabel* pickerLa.........
    ▪ ADT21抢鲜应用       ADT21抢鲜使用 伴着Android4.2的发布,楼主我也更新到了API17,adt换成21,抢鲜播报一下新变化。首先是新建工程,系统提供了几个新模板这个LoginActivity让人眼前一亮,并且Activity的代码都已.........

[1][新闻资讯] [业界动态] 一个轻量级的强大的组件库-as搬动开发者
    来源: 互联网  发布时间: 2014-02-18
[新闻资讯] [业界动态] 一个轻量级的强大的组件库--as移动开发者
资讯类型: 翻译
来源页面: http://madskool.wordpress.com/2011/05/11/using-madcomponents-with-minimalcomps-or-flobile-libraries/
资讯原标题: Using MadComponents with MinimalComps or Flobile libraries
资讯原作者: Daniel Freeman
翻译词数: 300 词
我的评论:MadComponents 功能比较强大,方便使用。
对这篇文你有啥看法,跟贴说说吧!欢迎口水和板砖,哈哈。欢迎大家和我们一同分享更多资讯。
在最近的MadComponent(0.3)更新中,添加了 divided list,search bar,activity indicator以及 navigation bar。
在这下载最新版本的源码还有文档。
http://code.google.com/p/mad-components/downloads/list
Flex(Flash Builder)在这用svn库这获得一些例子。http://code.google.com/p/mad-components/source/checkout
Flash用户可以按照下面的教程来使用MadComponents做一些移动设备上的应用。
http://madskool.wordpress.com/2011/04/24/getting-started-with-madcomponents-in-flash/

MadComponents并不是as移动开发者的唯一选择。它相对来说比较新,除它之外还有Keith Peter’s 的MinimalComps
http://www.minimalcomps.com/,Derek Grigg’s的 skinning libraryhttp://dgrigg.com/blog/2010/04/28/Alpha-Release-of-Skinnable-Minimal-Components/还有Todd Anderson’s 的as3Flobilehttp://custardbelly.com/blog/?p=173。这几个都比较受用。(但这些组件主要还是用于桌面应用而不是移动开发)。

但是如果你要是用Madcomponents的话,你就觉得真是爽呆了。因为在用Madcomponents时能够用其他的组件库里的组件来布局。
这个是拿Minimal comp与derek Grigg`s的组件扩举的例子。
package {
        import com.bit101.components.*;
        import com.dgrigg.skins.*;
        import com.danielfreeman.madcomponents.*;

        import flash.display.Sprite;
        import flash.display.StageAlign;
        import flash.display.StageScaleMode;

        public class MadDemo extends Sprite {

                protected static const LAYOUT:XML = <vertical xmlns:minimal="com.bit101.components">
                                                        <minimal:PushButton label="push me" alignH="fill" height="32" skin/>
                                                </vertical>;

                protected static const USES:Array = [PushButton,ButtonImageSkin,Knob];

                public function MadDemo() {
                        stage.scaleMode = StageScaleMode.NO_SCALE;
                        stage.align = StageAlign.TOP_LEFT;

                        UI.create(this, LAYOUT);
                }
        }
}


注意USES这个变量,我不清楚为什么如果这个组件没有被引用,你就需要在一个空语句中引用它。 可能这是Flash Builder的bug?
举另一个例子。用Flobile的picker组件。
package {
        import com.custardbelly.as3flobile.controls.label.Label;
        import com.custardbelly.as3flobile.controls.picker.Picker;
        import com.custardbelly.as3flobile.controls.picker.PickerColumn;
        import com.danielfreeman.madcomponents.*;

        import flash.display.Sprite;
        import flash.display.StageAlign;
        import flash.display.StageScaleMode;
        import flash.text.engine.ElementFormat;
        import flash.utils.getQualifiedClassName;

        public class MadPickerUI extends Sprite {

                protected static const LAYOUT:XML = <vertical xmlns:flobile="com.custardbelly.as3flobile.controls.picker">
                                                        <flobile:Picker id="picker" itemHeight="50" alignH="fill"/>
                                                        <image />
                                                        <label id="day"/>
                                                        <label id="month"/>
                                                        <label id="year"/>
                                                </vertical>;

                protected var _picker:Picker;
                protected var _day:UILabel;
                protected var _month:UILabel;
                protected var _year:UILabel;

                public function MadPickerUI() {
                        stage.scaleMode = StageScaleMode.NO_SCALE;
                        stage.align = StageAlign.TOP_LEFT;

                        UI.create(this, LAYOUT);

                        _day = UILabel(UI.findViewById("day"));
                        _month = UILabel(UI.findViewById("month"));
                        _year = UILabel(UI.findViewById("year"));

                        var dataProvider:Vector.<PickerColumn> = new Vector.<PickerColumn>();
                        dataProvider.push( getPickerColumnMonths() );
                        dataProvider.push( getPickerColumnDays( 50 ) );
                        dataProvider.push( getPickerColumnYears( 80 ) );

                        _picker = Picker(UI.findViewById("picker"));
                        _picker.selectionChange.add( pickerSelectionDidChange );
                        _picker.dataProvider = dataProvider;
                }

                protected function getPickerColumnDays( width:Number = Number.NaN ):PickerColumn {
                        var column:PickerColumn = new PickerColumn(); //null, getQualifiedClassName(CustomPickerColumnItemRenderer));
                        for( var i:int = 0; i < 31; i++ ) {
                                column.data.push( {label:( i + 1 ).toString()} );
                        }
                        column.width = width;
                        return column;
                }

                protected function getPickerColumnMonths( width:Number = Number.NaN ):PickerColumn {
                        var column:PickerColumn = new PickerColumn(); //null, getQualifiedClassName(CustomPickerColumnItemRenderer));
                        column.data = [{label:"January"}, {label:"February"}, {label:"March"}, {label:"April"}, {label:"May"}, {label:"June"}, {label:"July"},
                                {label:"August"}, {label:"September"}, {label:"October"}, {label:"November"}, {label:"December"}];
                        column.width = width;
                        return column;
                }

                protected function getPickerColumnYears( width:Number = Number.NaN ):PickerColumn {
                        var column:PickerColumn = new PickerColumn(); //null, getQualifiedClassName(CustomPickerColumnItemRenderer));
                        var i:int = 50;
                        while( --i > -1 ) {
                                column.data.push( {label:(1973 + i).toString()} );
                        }
                        column.width = width;
                        return column;
                }

                protected function pickerSelectionDidChange( column:PickerColumn, index:int ):void {
                        var columnIndex:int = _picker.dataProvider.indexOf( column );
                        if (columnIndex==0) {
                                _day.text = column.data[index].label;
                        }
                        else if (columnIndex==1) {
                                _month.text = column.data[index].label;
                        }
                        else {
                                _year.text = column.data[index].label;
                        }
                }
        }
}


    
[2] UIPickerView控件中自定义展示的字体大小及样式
    来源: 互联网  发布时间: 2014-02-18
UIPickerView控件中自定义显示的字体大小及样式

通过覆盖如下方法实现

- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view{
    UILabel* pickerLabel = (UILabel*)view;
    if (!pickerLabel){
        pickerLabel = [[UILabel alloc] init];
        // Setup label properties - frame, font, colors etc
        //adjustsFontSizeToFitWidth property to YES
        pickerLabel.minimumFontSize = 8.;
        pickerLabel.adjustsFontSizeToFitWidth = YES;
        [pickerLabel setTextAlignment:UITextAlignmentLeft];
        [pickerLabel setBackgroundColor:[UIColor clearColor]];
        [pickerLabel setFont:[UIFont boldSystemFontOfSize:15]];
    }
    // Fill the label text here
    pickerLabel.text=[self pickerView:pickerView titleForRow:row forComponent:component];
    return pickerLabel;
}
 

 


    
[3] ADT21抢鲜应用
    来源: 互联网  发布时间: 2014-02-18
ADT21抢鲜使用
伴着Android4.2的发布,楼主我也更新到了API17,adt换成21,抢鲜播报一下新变化。
首先是新建工程,系统提供了几个新模板


这个LoginActivity让人眼前一亮,并且Activity的代码都已经写好了,开发起来so easy!
这个MasterDetailFlow据IOS的同事说在苹果SDK早就有了,看来谷歌是迎面赶上啊。
再来看一张布局器


多个屏幕尺寸的预览图同时展示,更好的进行屏幕适配工作
下面是LoginActivity的代码
package com.example.adt21test;

import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.annotation.TargetApi;
import android.app.Activity;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.View;
import android.view.inputmethod.EditorInfo;
import android.widget.EditText;
import android.widget.TextView;

/**
 * Activity which displays a login screen to the user, offering registration as
 * well.
 */
public class LoginActivity extends Activity {
	/**
	 * A dummy authentication store containing known user names and passwords.
	 * TODO: remove after connecting to a real authentication system.
	 */
	private static final String[] DUMMY_CREDENTIALS = new String[] {
			"foo@example.com:hello", "bar@example.com:world" };

	/**
	 * The default email to populate the email field with.
	 */
	public static final String EXTRA_EMAIL = "com.example.android.authenticatordemo.extra.EMAIL";

	/**
	 * Keep track of the login task to ensure we can cancel it if requested.
	 */
	private UserLoginTask mAuthTask = null;

	// Values for email and password at the time of the login attempt.
	private String mEmail;
	private String mPassword;

	// UI references.
	private EditText mEmailView;
	private EditText mPasswordView;
	private View mLoginFormView;
	private View mLoginStatusView;
	private TextView mLoginStatusMessageView;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		setContentView(R.layout.activity_login);

		// Set up the login form.
		mEmail = getIntent().getStringExtra(EXTRA_EMAIL);
		mEmailView = (EditText) findViewById(R.id.email);
		mEmailView.setText(mEmail);

		mPasswordView = (EditText) findViewById(R.id.password);
		mPasswordView
				.setOnEditorActionListener(new TextView.OnEditorActionListener() {
					@Override
					public boolean onEditorAction(TextView textView, int id,
							KeyEvent keyEvent) {
						if (id == R.id.login || id == EditorInfo.IME_NULL) {
							attemptLogin();
							return true;
						}
						return false;
					}
				});

		mLoginFormView = findViewById(R.id.login_form);
		mLoginStatusView = findViewById(R.id.login_status);
		mLoginStatusMessageView = (TextView) findViewById(R.id.login_status_message);

		findViewById(R.id.sign_in_button).setOnClickListener(
				new View.OnClickListener() {
					@Override
					public void onClick(View view) {
						attemptLogin();
					}
				});
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		super.onCreateOptionsMenu(menu);
		getMenuInflater().inflate(R.menu.activity_login, menu);
		return true;
	}

	/**
	 * Attempts to sign in or register the account specified by the login form.
	 * If there are form errors (invalid email, missing fields, etc.), the
	 * errors are presented and no actual login attempt is made.
	 */
	public void attemptLogin() {
		if (mAuthTask != null) {
			return;
		}

		// Reset errors.
		mEmailView.setError(null);
		mPasswordView.setError(null);

		// Store values at the time of the login attempt.
		mEmail = mEmailView.getText().toString();
		mPassword = mPasswordView.getText().toString();

		boolean cancel = false;
		View focusView = null;

		// Check for a valid password.
		if (TextUtils.isEmpty(mPassword)) {
			mPasswordView.setError(getString(R.string.error_field_required));
			focusView = mPasswordView;
			cancel = true;
		} else if (mPassword.length() < 4) {
			mPasswordView.setError(getString(R.string.error_invalid_password));
			focusView = mPasswordView;
			cancel = true;
		}

		// Check for a valid email address.
		if (TextUtils.isEmpty(mEmail)) {
			mEmailView.setError(getString(R.string.error_field_required));
			focusView = mEmailView;
			cancel = true;
		} else if (!mEmail.contains("@")) {
			mEmailView.setError(getString(R.string.error_invalid_email));
			focusView = mEmailView;
			cancel = true;
		}

		if (cancel) {
			// There was an error; don't attempt login and focus the first
			// form field with an error.
			focusView.requestFocus();
		} else {
			// Show a progress spinner, and kick off a background task to
			// perform the user login attempt.
			mLoginStatusMessageView.setText(R.string.login_progress_signing_in);
			showProgress(true);
			mAuthTask = new UserLoginTask();
			mAuthTask.execute((Void) null);
		}
	}

	/**
	 * Shows the progress UI and hides the login form.
	 */
	@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2)
	private void showProgress(final boolean show) {
		// On Honeycomb MR2 we have the ViewPropertyAnimator APIs, which allow
		// for very easy animations. If available, use these APIs to fade-in
		// the progress spinner.
		if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
			int shortAnimTime = getResources().getInteger(
					android.R.integer.config_shortAnimTime);

			mLoginStatusView.setVisibility(View.VISIBLE);
			mLoginStatusView.animate().setDuration(shortAnimTime)
					.alpha(show ? 1 : 0)
					.setListener(new AnimatorListenerAdapter() {
						@Override
						public void onAnimationEnd(Animator animation) {
							mLoginStatusView.setVisibility(show ? View.VISIBLE
									: View.GONE);
						}
					});

			mLoginFormView.setVisibility(View.VISIBLE);
			mLoginFormView.animate().setDuration(shortAnimTime)
					.alpha(show ? 0 : 1)
					.setListener(new AnimatorListenerAdapter() {
						@Override
						public void onAnimationEnd(Animator animation) {
							mLoginFormView.setVisibility(show ? View.GONE
									: View.VISIBLE);
						}
					});
		} else {
			// The ViewPropertyAnimator APIs are not available, so simply show
			// and hide the relevant UI components.
			mLoginStatusView.setVisibility(show ? View.VISIBLE : View.GONE);
			mLoginFormView.setVisibility(show ? View.GONE : View.VISIBLE);
		}
	}

	/**
	 * Represents an asynchronous login/registration task used to authenticate
	 * the user.
	 */
	public class UserLoginTask extends AsyncTask<Void, Void, Boolean> {
		@Override
		protected Boolean doInBackground(Void... params) {
			// TODO: attempt authentication against a network service.

			try {
				// Simulate network access.
				Thread.sleep(2000);
			} catch (InterruptedException e) {
				return false;
			}

			for (String credential : DUMMY_CREDENTIALS) {
				String[] pieces = credential.split(":");
				if (pieces[0].equals(mEmail)) {
					// Account exists, return true if the password matches.
					return pieces[1].equals(mPassword);
				}
			}

			// TODO: register the new account here.
			return true;
		}

		@Override
		protected void onPostExecute(final Boolean success) {
			mAuthTask = null;
			showProgress(false);

			if (success) {
				finish();
			} else {
				mPasswordView
						.setError(getString(R.string.error_incorrect_password));
				mPasswordView.requestFocus();
			}
		}

		@Override
		protected void onCancelled() {
			mAuthTask = null;
			showProgress(false);
		}
	}
}



稍微改一改就能用,Android程序员的春天越来越近了

    
最新技术文章:
▪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(请将#改为@)

编程技术其它 iis7站长之家