samedi 8 mars 2014

MultiAutocomplete error


Vote count:

0




I'm trying to do an autocomplete activity in which when the user write a word, it gives suggestions.



My codes for item.java :

public class item extends Activity {

private MultiAutoCompleteTextView mactv;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.item);

String[] items = getResources().
getStringArray(R.array.list_of_items);
ArrayAdapter adapter = new ArrayAdapter
(this,android.R.layout.simple_list_item_1,items);

mactv = (MultiAutoCompleteTextView)findViewById(R.id.multiAutoCompleteTextView1);

mactv.setAdapter(adapter);

mactv.setTokenizer(new MultiAutoCompleteTextView.CommaTokenizer());}

@Override
public boolean onCreateOptionsMenu(Menu menu) {

getMenuInflater().inflate(R.menu.main, menu);
return true; }}


item.xml :



<RelativeLayout xmlns:android="http://ift.tt/nIICcg"
xmlns:tools="http://ift.tt/LrGmb4"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<MultiAutoCompleteTextView
android:id="@+id/multiAutoCompleteTextView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="48dp"
android:ems="10" >
<requestFocus />
</MultiAutoCompleteTextView>
</RelativeLayout>


string.xml :



<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">DailyExpenseManager</string>
<string name="action_settings">Settings</string>
<string name="hello_world">Hello world!</string>
<string-array name="list_of_items">
<item >picon</item>
<item >kiri</item>
<item >nutella</item>
<item >pringles</item>
<item >chips</item>
<item >chocolat</item>
<item >galaxy</item>
<item >twix</item>
<item >snack</item>
</string-array>
</resources>


androidManifest.xml :



<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://ift.tt/nIICcg"
package="com.example.DailyExpenseManager"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.DailyExpenseManager.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>


I have an error in R ( R cannot be resolved to a variable ), I clean and build but the error still occur


Any help please



asked 43 secs ago






Aucun commentaire:

Enregistrer un commentaire