Android: tags autocompletion (in progress)

This commit is contained in:
jendib 2014-12-03 00:28:26 +01:00
parent a181eac9a5
commit a7987386e1
6 changed files with 51 additions and 3 deletions

View File

@ -105,6 +105,7 @@
<orderEntry type="library" exported="" name="support-v4-21.0.2" level="project" />
<orderEntry type="library" exported="" name="eventbus-2.4.0" level="project" />
<orderEntry type="library" exported="" name="android-query.0.26.8" level="project" />
<orderEntry type="library" exported="" name="tokenautocomplete-1.2.1" level="project" />
<orderEntry type="library" exported="" name="appcompat-v7-21.0.2" level="project" />
<orderEntry type="library" exported="" name="android-async-http-1.4.6" level="project" />
</component>

Binary file not shown.

View File

@ -37,7 +37,6 @@ public class DocumentEditActivity extends ActionBarActivity {
MultiAutoCompleteTextView tagsEditText = (MultiAutoCompleteTextView) findViewById(R.id.tagsEditText);
tagsEditText.setAdapter(new ArrayAdapter<>(this, android.R.layout.simple_spinner_dropdown_item,
new String[]{"Caluire", "Appartement", "Banque", "Assurance"}));
tagsEditText.setTokenizer(new MultiAutoCompleteTextView.CommaTokenizer());
}
@Override

View File

@ -0,0 +1,34 @@
package com.sismics.docs.ui.view;
import android.app.Activity;
import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.sismics.docs.R;
import com.tokenautocomplete.TokenCompleteTextView;
public class TagsCompleteTextView extends TokenCompleteTextView {
public TagsCompleteTextView(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
protected View getViewForObject(Object object) {
String p = (String)object;
LayoutInflater inflater = (LayoutInflater)getContext().getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
TextView view = (TextView) inflater.inflate(R.layout.tag_complete_item, (ViewGroup) getParent(), false);
view.setText(p);
return view;
}
@Override
protected Object defaultObject(String completionText) {
return completionText;
}
}

View File

@ -58,7 +58,7 @@
android:layout_margin="8dp"
android:padding="16dp"/>
<MultiAutoCompleteTextView
<com.sismics.docs.ui.view.TagsCompleteTextView
android:id="@+id/tagsEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/edtTxt1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#ccc"
android:drawablePadding="2dp"
android:padding="8dp"
android:shadowColor="#FFFFFF"
android:shadowDy="1"
android:shadowRadius="0.01"
android:textColor="#000000"
android:textSize="18sp"
android:textStyle="bold" />