• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

kpbird/chips-edittext-library: Chips EditText, Token EditText, Bubble EditText, ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

kpbird/chips-edittext-library

开源软件地址(OpenSource Url):

https://github.com/kpbird/chips-edittext-library

开源编程语言(OpenSource Language):


开源软件介绍(OpenSource Introduction):

Chips EditText Library

Chips EditText, Token EditText, Bubble EditText, Spannable EditText and etc.. There are many names of this control. Here I develop easy to understand , modify and integrate Chips Edit Text widget for Android

=============

Alt text

Step 1: Clone git repor or download zip file

Step 2: Import ChipsEditTextLibrary in your eclipse workspace

Step 3: Create new Android project

Step 4: Set ChipsEditTextLibrary as reference of your project

Alt text

Right Click on Project -> Properties -> Android ->Add

Step 4: Open your xml layout file and add ChipsEditText control

  <com.kpbird.chipsedittextlibrary.ChipsMultiAutoCompleteTextview
        android:id="@+id/chipsMultiAutoCompleteTextview1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:ems="10"
        android:text="" >

        <requestFocus />
    </com.kpbird.chipsedittextlibrary.ChipsMultiAutoCompleteTextview>

Step 5: Open your Activity class and write following code.

  package com.kpbird.chipsedittextdemo;

  import java.util.ArrayList;

  import android.app.Activity;
  import android.content.res.TypedArray;
  import android.os.Bundle;
  import android.util.Log;
  
  import com.kpbird.chipsedittextlibrary.ChipsAdapter;
  import com.kpbird.chipsedittextlibrary.ChipsItem;
  import com.kpbird.chipsedittextlibrary.ChipsMultiAutoCompleteTextview;
  
  public class MainActivity extends Activity {
  
 @Override
 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);

  ChipsMultiAutoCompleteTextview ch = (ChipsMultiAutoCompleteTextview) findViewById(R.id.chipsMultiAutoCompleteTextview1);

  String[] countries = getResources().getStringArray(R.array.country);
  TypedArray imgs = getResources().obtainTypedArray(R.array.flags);

  ArrayList<ChipsItem> arrCountry = new ArrayList<ChipsItem>();

  for (int i = 0; i < countries.length; i++) {
   arrCountry.add(new ChipsItem(countries[i], imgs
     .getResourceId(i, -1)));
   Log.i("Main Activity", arrCountry.get(i).getTitle() + " = "
     + arrCountry.get(i).getImageid());
  }

  Log.i("MainActivity", "Array :" + arrCountry.size());

  ChipsAdapter chipsAdapter = new ChipsAdapter(this, arrCountry);
  ch.setAdapter(chipsAdapter);

 }

}

Step 6: You need to use ChipsItem and ChipsAdapter to provide data. ChipsItem has two field 1. Title and 2. Image Id (R.drawable.android), In above sample I have created two array in string.xml for title and images.

For more detail please refer : http://www.kpbird.com/2013/02/android-chips-edittext-token-edittext_26.html




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap