当前位置: 编程技术>移动开发
本页文章导读:
▪AutoCompleteTextView跟MultiAutoCompleteTextView AutoCompleteTextView和MultiAutoCompleteTextView
http://imshare.iteye.com/blog/771539http://windywindy.iteye.com/blog/464152MultiAutoCompleteTextView也是具有自动完成提示的功能,它和AutoCompleteTextView的区别就是MultiAutoComple.........
▪ 《Maven 实战》读书笔记(7) 聚合 《Maven 实战》读书笔记(七) 聚合
1. 继承之前我们学习Maven的聚合机制遗留个问题,就是多个模块的pom.xml文件的内容出现了冗余、重复的内容,解决这个问题其实使用Maven的继承机制即.........
▪ Gallery 画廊成效 Gallery 画廊效果
http://www.cnblogs.com/nokiaguy/archive/2010/08/23/1806870.htmlhttp://smallnopoint.iteye.com/blog/7255181.首先创建实现OnItemSelectedListener,ViewFactory类。2.创建ImageAdapter类。3.Activity类。MyOnItemSelectedList.........
[1]AutoCompleteTextView跟MultiAutoCompleteTextView
来源: 互联网 发布时间: 2014-02-18
AutoCompleteTextView和MultiAutoCompleteTextView
http://imshare.iteye.com/blog/771539
http://windywindy.iteye.com/blog/464152
MultiAutoCompleteTextView也是具有自动完成提示的功能,它和AutoCompleteTextView的区别就是MultiAutoCompleteTextView可以在输入框中一直增加新的选取值。编写方式也有所不同,在进行setAdapter之后还需要调用setTokenizer(),否则会出现错误
http://imshare.iteye.com/blog/771539
http://windywindy.iteye.com/blog/464152
MultiAutoCompleteTextView也是具有自动完成提示的功能,它和AutoCompleteTextView的区别就是MultiAutoCompleteTextView可以在输入框中一直增加新的选取值。编写方式也有所不同,在进行setAdapter之后还需要调用setTokenizer(),否则会出现错误
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello" />
<AutoCompleteTextView
android:id="@+id/autoCompleteTextView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="" >
<requestFocus />
</AutoCompleteTextView>
<MultiAutoCompleteTextView
android:id="@+id/multiAutoCompleteTextView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="" />
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView" />
</LinearLayout>package pandy.auto.test;
import android.app.Activity;
import android.os.Bundle;
import android.widget.Adapter;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
import android.widget.MultiAutoCompleteTextView;
public class AutoCompleteTestActivity extends Activity {
private AutoCompleteTextView autoCompleteTextView1;
private MultiAutoCompleteTextView multiAutoCompleteTextView1;
private String[] allData = new String[]{"China","Russia","Germany",
"Ukraine","Belarus","USA","China1","China2","USA1"};
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
autoCompleteTextView1 = (AutoCompleteTextView)findViewById(R.id.autoCompleteTextView1);
multiAutoCompleteTextView1 = (MultiAutoCompleteTextView)findViewById(R.id.multiAutoCompleteTextView1);
ArrayAdapter adapter = new ArrayAdapter(this,android.R.layout.simple_dropdown_item_1line,allData);
autoCompleteTextView1.setAdapter(adapter);
autoCompleteTextView1.setThreshold(1);
multiAutoCompleteTextView1.setAdapter(adapter);
multiAutoCompleteTextView1.setThreshold(1);
multiAutoCompleteTextView1.setTokenizer(new MultiAutoCompleteTextView.CommaTokenizer());
}
}
[2] 《Maven 实战》读书笔记(7) 聚合
来源: 互联网 发布时间: 2014-02-18
《Maven 实战》读书笔记(七) 聚合
1. 继承
之前我们学习Maven的聚合机制遗留个问题,就是多个模块的pom.xml文件的内容出现了冗余、重复的内容,解决这个问题其实使用Maven的继承机制即可,就像Java的继承一样,父类就像一个模板,子类继承自父类,那么有些通用的方法、变量都不必在子类中再重复声明了,具体Java继承在内存中的表现形式可以参考
http://suhuanzheng7784877.iteye.com/blog/1000635
和http://suhuanzheng7784877.iteye.com/blog/1000700 中的部分内容。Maven的继承机制类似,在一个父级别的Maven的pom文件中定义了相关的常量、依赖、插件等等配置后,实际项目模块可以继承此父项目的pom文件,重复的项不必显示的再声明一遍了,相当于父Maven项目就是个模板,等着其他子模块去继承。不过父Maven项目要高度抽象,高度提取公共的部分(交集)。笔者使用了先前的聚合项目模块做的父模板pom,实际上很多机构也是这么实施的。
这个pom文件即描述了通用的依赖模板,也列举出了聚合的模块,放心modules不会被继承。下面我们来改造一下之前的两个模块
邮件模块pom.xml
注册模块
pom.xml
1. 继承
之前我们学习Maven的聚合机制遗留个问题,就是多个模块的pom.xml文件的内容出现了冗余、重复的内容,解决这个问题其实使用Maven的继承机制即可,就像Java的继承一样,父类就像一个模板,子类继承自父类,那么有些通用的方法、变量都不必在子类中再重复声明了,具体Java继承在内存中的表现形式可以参考
http://suhuanzheng7784877.iteye.com/blog/1000635
和http://suhuanzheng7784877.iteye.com/blog/1000700 中的部分内容。Maven的继承机制类似,在一个父级别的Maven的pom文件中定义了相关的常量、依赖、插件等等配置后,实际项目模块可以继承此父项目的pom文件,重复的项不必显示的再声明一遍了,相当于父Maven项目就是个模板,等着其他子模块去继承。不过父Maven项目要高度抽象,高度提取公共的部分(交集)。笔者使用了先前的聚合项目模块做的父模板pom,实际上很多机构也是这么实施的。
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.liuyan.account</groupId>
<artifactId>MavenAccount-aggregator</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<properties>
<springversion>2.5.6</springversion>
<junitversion>2.5.6</junitversion>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${springversion}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>${springversion}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${springversion}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>${springversion}</version>
</dependency>
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>1.4.1</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.7</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.icegreen</groupId>
<artifactId>greenmail</artifactId>
<version>1.3.1b</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<resources>
<resource>
<directory>src/main/resource</directory>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.1.1</version>
<executions>
<execution>
<id>buildSource</id>
<goals>
<goal>jar-no-fork</goal>
</goals>
<inherited>false</inherited>
<configuration>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<target>1.5</target>
</configuration>
</plugin>
</plugins>
</build>
<modules>
<module>../MavenAccount-email</module>
<module>../MavenAccount-persist</module>
</modules>
</project> 这个pom文件即描述了通用的依赖模板,也列举出了聚合的模块,放心modules不会被继承。下面我们来改造一下之前的两个模块
邮件模块pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>MavenAccount-email</artifactId>
<packaging>jar</packaging>
<parent>
<groupId>com.liuyan.account</groupId>
<artifactId>MavenAccount-aggregator</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../MavenAccount-aggregator/pom.xml</relativePath>
</parent>
</project> 注册模块
pom.xml
[3] Gallery 画廊成效
来源: 互联网 发布时间: 2014-02-18
Gallery 画廊效果
http://www.cnblogs.com/nokiaguy/archive/2010/08/23/1806870.html
http://smallnopoint.iteye.com/blog/725518
1.首先创建实现OnItemSelectedListener,ViewFactory类。
2.创建ImageAdapter类。
3.Activity类。
MyOnItemSelectedListener:当Gallery被选择的时候,把被选择的图片放到ImageSwitch里面去。
MyImageAdapter:实现Gallery显示的图片。
ViewFactory:ImageSwitch的显示工厂。
main.xml
MyOnItemSelectedListener.java
-----------------------
MyImageAdapter.java
----------------------
ViewFactory类
-----------------------
Activity类
---------------------------
http://www.cnblogs.com/nokiaguy/archive/2010/08/23/1806870.html
http://smallnopoint.iteye.com/blog/725518
1.首先创建实现OnItemSelectedListener,ViewFactory类。
2.创建ImageAdapter类。
3.Activity类。
MyOnItemSelectedListener:当Gallery被选择的时候,把被选择的图片放到ImageSwitch里面去。
MyImageAdapter:实现Gallery显示的图片。
ViewFactory:ImageSwitch的显示工厂。
main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello" />
<Gallery
android:id="@+id/gallery1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"/>
<ImageSwitcher android:id="@+id/imageswitcher1"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true">
</ImageSwitcher>
</LinearLayout>MyOnItemSelectedListener.java
-----------------------
package com.gallery;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ImageSwitcher;
public class MyOnItemSelectedListener implements OnItemSelectedListener{
private ImageSwitcher imageswitcher1;
private int[] images;
public MyOnItemSelectedListener(ImageSwitcher imageswitcher1,int[] images){
this.imageswitcher1 = imageswitcher1;
this.images = images;
}
@Override
public void onItemSelected(AdapterView<?> arg0, View arg1, int position,
long arg3) {
// 第2点改进,通过取余来循环取得images数组中的图像资源ID
imageswitcher1.setImageResource(images[position % images.length]);
}
@Override
public void onNothingSelected(AdapterView<?> arg0) {
// TODO Auto-generated method stub
}
}
MyImageAdapter.java
----------------------
package com.gallery;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Gallery;
import android.widget.ImageView;
public class MyImageAdapter extends BaseAdapter {
public Context context;
private int[] images;
public MyImageAdapter(Context context,int[]images){
this.context = context;
this.images = images;
}
@Override
public int getCount() {
//获得图片的总数,这里设定为最大值,是为了模拟循环显示
return Integer.MAX_VALUE;
}
@Override
public Object getItem(int arg0) {
return null;
}
@Override
public long getItemId(int position) {
return 0;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ImageView imageView = new ImageView(context);
// 第2点改进,通过取余来循环取得images数组中的图像资源ID
imageView.setImageResource(images[position % images.length]);
imageView.setScaleType(ImageView.ScaleType.FIT_XY);
imageView.setLayoutParams(new Gallery.LayoutParams(100, 100));
//imageView.setBackgroundResource(mGalleryItemBackground);
return imageView;
}
}
ViewFactory类
-----------------------
package com.gallery;
import android.app.ActionBar.LayoutParams;
import android.content.Context;
import android.view.View;
import android.widget.ImageSwitcher;
import android.widget.ImageView;
import android.widget.ViewSwitcher.ViewFactory;
public class MyViewFactory implements ViewFactory {
private Context context;
public MyViewFactory(Context context){
this.context = context;
}
@Override
public View makeView() {
ImageView i = new ImageView(context);
i.setBackgroundColor(0xFF000000);
i.setScaleType(ImageView.ScaleType.FIT_CENTER);
i.setLayoutParams(new ImageSwitcher.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
return i;
}
}
Activity类
---------------------------
package com.gallery;
import android.app.Activity;
import android.os.Bundle;
import android.view.animation.AnimationUtils;
import android.widget.Gallery;
import android.widget.ImageSwitcher;
public class MyGalleryActivity extends Activity{
private Gallery gallery1;
private ImageSwitcher imageswitcher1;
private int[] images = new int[] { R.drawable.android0001, R.drawable.android0002, R.drawable.android0003, R.drawable.android0004, R.drawable.android0005, R.drawable.android0006, R.drawable.android0007, R.drawable.android0008 };
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
imageswitcher1 = (ImageSwitcher)findViewById(R.id.imageswitcher1);
imageswitcher1.setFactory(new MyViewFactory(MyGalleryActivity.this));
imageswitcher1.setInAnimation(AnimationUtils.loadAnimation(this, android.R.anim.fade_in));
imageswitcher1.setOutAnimation(AnimationUtils.loadAnimation(this, android.R.anim.fade_out));
gallery1 = (Gallery)findViewById(R.id.gallery1);
gallery1.setAdapter(new MyImageAdapter(this,images));
gallery1.setOnItemSelectedListener(new MyOnItemSelectedListener(imageswitcher1,images));
}
}最新技术文章: