i want to choose the contacts from a list view (which seems to work) - and populate the chosen contact in another ui (and then send a generated message to the chosen contact by sms). The populateField method doesn't work.
Here snippets from my code:
the layout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/yellow"
android:orientation="vertical" >
<TextView
android:id="#+id/label_sms_number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/label_sms_number"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/black" />
<TextView
android:id="#+id/display_sendSms_name_contact"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/black" />
<TextView
android:id="#+id/display_sendSms_contact_number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/black" />
<TextView
android:id="#+id/label_sms_message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/label_sms_message"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/black" />
<EditText
android:id="#+id/input_sms_message"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textMultiLine" >
<requestFocus />
</EditText>
<Button
android:id="#+id/button_sms_send"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/label_sms_button_send" />
</LinearLayout>
my java code:
public class SendSMS extends Activity{
private IShoppingListDao shoppingManager;
private TextView mContact;
private TextView mMessage;
private Long mRowId;
private static final String TAG = "SendSMS";
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.send_list_by_sms);
shoppingManager = new ShoppingListDao(this);
shoppingManager.open();
mContact = (TextView) findViewById(R.id.display_sendSms_name_contact);
mRowId = null;
Bundle extras = getIntent().getExtras();
mRowId = (savedInstanceState == null) ? null : (Long) savedInstanceState
.getSerializable(ContactsContract.Contacts.DISPLAY_NAME);
Log.d(TAG, "Row-id: "+mRowId);
if (extras != null) {
mRowId = extras.getLong(ContactsContract.Contacts.DISPLAY_NAME);
}
mMessage = (TextView) findViewById(R.id.input_sms_message);
mMessage.setText(generateMessage());
populateFields();
}
private void populateFields() {
Log.d(TAG,"Entering populateFields");
Log.d(TAG,"Row-id: "+mRowId);
if (mRowId != null) {
ContentResolver cr = getContentResolver();
String where = ContactsContract.Contacts._ID + " = " + mRowId;
Log.d(TAG,"String where: "+where);
//selecting the name
Cursor listItem = cr.query(
ContactsContract.Contacts.CONTENT_URI,
null,
where,
null, null);
startManagingCursor(listItem);
mContact.setText(listItem.getString(
listItem.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME)));
}
}
Related
I am having an issue with scrolling of ListView in a Popup. I have an activity that has a dialog theme so that it can open up as a popup. The Popup should contain EditText at the bottom and the remaining area above it should be the ListView. When the activity is started it should start with keypad open & focus on EditText.
Issue: ListView doesn't scroll when keypad is open.
Below is my activity code:
public class CommentsActivity extends Activity{
private InputMethodManager imm;
private String commentCount;
private ShopPirateDatabase db;
private ArrayList<CommentsBean> commentsList = new ArrayList<CommentsBean>();
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.comments_layout);
imm = (InputMethodManager) this
.getSystemService(Context.INPUT_METHOD_SERVICE);
db=new ShopPirateDatabase(this);
if(getIntent().hasExtra("count")){
commentCount=getIntent().getExtras().getString("count");
}
ListView lvMyComments=(ListView)findViewById(R.id.lvMyComments);
lvMyComments.setVisibility(View.GONE);
final Button btnPost=(Button)findViewById(R.id.btnPost);
btnPost.setVisibility(View.GONE);
etAddComment=(EditText)findViewById(R.id.etAddComment);
RelativeLayout progressLayout=(RelativeLayout)findViewById(R.id.progressLayout);
progressLayout.setVisibility(View.VISIBLE);
TextView tvNoComments=(TextView)findViewById(R.id.tvNoComments);
tvNoComments.setVisibility(View.GONE);
imm.showSoftInput(etAddComment, InputMethodManager.SHOW_IMPLICIT);
if(Integer.parseInt(commentCount) > 0){
getCommentsFromDb();
if(commentsList!=null && commentsList.size() > 0){
progressLayout.setVisibility(View.GONE);
tvNoComments.setVisibility(View.GONE);
lvMyComments.setVisibility(View.VISIBLE);
CommentsAdapter commentsAdapter = new CommentsAdapter(
CommentsActivity.this, commentsList);
lvMyComments.setAdapter(commentsAdapter);
}
} else{
progressLayout.setVisibility(View.GONE);
tvNoComments.setVisibility(View.VISIBLE);
lvMyComments.setVisibility(View.GONE);
}
}
private void getCommentsFromDb() {
db.openDatabase();
Cursor c = db.getComments();
if (c != null) {
commentsList = null;
commentsList = new ArrayList<CommentsBean>();
if (c.moveToFirst()) {
do {
CommentsBean mBeanClass = new CommentsBean();
mBeanClass
.setCommentText(c.getString(c
.getColumnIndex(db.KEY_COMMENT_TEXT)));
mBeanClass
.setCommentedDate(c.getString(c
.getColumnIndex(db.KEY_COMMENT_DATE)));
mBeanClass
.setCommentedBy(c.getString(c
.getColumnIndex(db.KEY_COMMENT_USER)));
commentsList.add(mBeanClass);
} while (c.moveToNext());
}
}
c.close();
db.closeDatabase();
}
}
comments_layout.xml
<RelativeLayout
android:id="#+id/commentsBox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true"
android:layout_marginBottom="#dimen/margin_5"
android:layout_marginLeft="#dimen/margin_2"
android:layout_marginRight="#dimen/margin_5" >
<Button
android:id="#+id/btnPost"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:minHeight="#dimen/margin_35"
android:background="#color/coupon_color"
android:paddingBottom="#dimen/margin_7"
android:paddingLeft="#dimen/margin_15"
android:paddingRight="#dimen/margin_15"
android:paddingTop="#dimen/margin_7"
android:layout_alignParentRight="true"
android:layout_marginRight="#dimen/margin_2"
android:text="Post"
android:visibility="gone"
android:textColor="#color/white"
android:textSize="#dimen/normal_textsize" />
<EditText
android:id="#+id/etAddComment"
android:layout_width="match_parent"
android:layout_alignParentLeft="true"
android:layout_marginLeft="#dimen/margin_2"
android:layout_toLeftOf="#id/btnPost"
android:layout_marginRight="#dimen/margin_2"
android:focusable="true"
android:focusableInTouchMode="true"
android:layout_height="wrap_content"
android:layout_marginBottom="#dimen/margin_5"
android:hint="#string/comment_hint" />
</RelativeLayout>
<ListView
android:id="#+id/lvMyComments"
android:layout_width="match_parent"
android:layout_height="300dp"
android:layout_marginBottom="#dimen/margin_5"
android:divider="#color/home_bg_color"
android:dividerHeight="#dimen/divider_height"
android:scrollbars="none"
android:visibility="gone" >
</ListView>
<RelativeLayout
android:id="#+id/progressLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#id/commentsBox"
android:layout_marginLeft="#dimen/margin_10"
android:layout_marginRight="#dimen/margin_10" >
<ProgressBar
android:id="#+id/pBarComments"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:indeterminate="true"
android:indeterminateDrawable="#drawable/circular_progress_bar" />
<TextView
android:id="#+id/tvWaitComments"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/pBarComments"
android:layout_centerHorizontal="true"
android:layout_marginLeft="#dimen/margin_5"
android:layout_marginRight="#dimen/margin_5"
android:text="Loading comments..."
android:textColor="#color/black"
android:textSize="#dimen/small_textsize" />
</RelativeLayout>
<TextView
android:id="#+id/tvNoComments"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#id/etAddComment"
android:layout_marginLeft="#dimen/margin_15"
android:layout_marginRight="#dimen/margin_25"
android:gravity="center_vertical|center_horizontal"
android:text="No comments have been posted for this offer"
android:textColor="#color/black"
android:textSize="#dimen/normal_textsize"
android:visibility="gone" />
CommentsAdapter.java
public class CommentsAdapter extends BaseAdapter {
private Context context;
private ArrayList<CommentsBean> mArrayList = new ArrayList<CommentsBean>();
public CommentsAdapter(Context ctx, ArrayList<CommentsBean> arrayList) {
this.context = ctx;
this.mArrayList = arrayList;
}
#Override
public int getCount() {
return mArrayList.size();
}
#Override
public Object getItem(int position) {
return null;
}
#Override
public long getItemId(int position) {
return 0;
}
#Override
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view;
view = null;
convertView = null;
if (convertView == null) {
view = new View(context);
view = inflater.inflate(R.layout.list_comments, null);
TextView commentText = (TextView) view
.findViewById(R.id.commentText);
TextView postedDate = (TextView) view.findViewById(R.id.postedDate);
TextView userName = (TextView) view.findViewById(R.id.userName);
commentText.setText(mArrayList.get(position).getCommentText());
userName.setText(" - " + mArrayList.get(position).getCommentedBy());
String dt = mArrayList.get(position).getCommentedDate();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date d = null;
try {
d = sdf.parse(dt);
} catch (ParseException e) {
e.printStackTrace();
}
SimpleDateFormat sdf1 = new SimpleDateFormat("dd-MM-yyyy");
String convertedDate = null;
convertedDate = sdf1.format(d);
postedDate.setText(convertedDate);
}
return view;
}
}
list_comments.xml
<ImageView android:id="#+id/cmtIcon"
android:layout_width="#dimen/margin_25"
android:layout_height="#dimen/margin_25"
android:src="#drawable/comment_list_icon"
android:layout_alignParentTop="true"
android:layout_marginTop="#dimen/margin_5"
android:layout_marginLeft="#dimen/margin_5"
android:layout_alignParentLeft="true" />
<TextView
android:id="#+id/commentText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/margin_10"
android:layout_toRightOf="#id/cmtIcon"
android:layout_alignParentTop="true"
android:layout_marginTop="#dimen/margin_5"
android:textColor="#color/black"
android:textSize="#dimen/normal_textsize" />
<TextView
android:id="#+id/postedDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/commentText"
android:layout_toRightOf="#id/cmtIcon"
android:layout_marginLeft="#dimen/margin_10"
android:layout_marginTop="#dimen/margin_5"
android:text="Posted on"
android:textColor="#color/black"
android:textSize="#dimen/small_textsize" />
<TextView
android:id="#+id/userName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#id/postedDate"
android:layout_marginTop="#dimen/margin_3"
android:text="User Name"
android:layout_below="#id/commentText"
android:textColor="#color/black"
android:textSize="#dimen/normal_textsize" />
public class MainActivity extends Activity {
TextView tID;
TextView tName;
TextView tWorld;
protected void onCreate(Bundle paramBundle) {
super.onCreate(paramBundle);
setContentView(R.layout.ps);
tID = (TextView) findViewById(R.id.tID);
tName = (TextView) findViewById(R.id.tName);
tWorld = (TextView) findViewById(R.id.tWorld);
}
public void Search(View view) {
int clist = -2;
String oID = "";
String oName = "";
String oWorld = "";
setContentView(R.layout.list);
while (clist != -1)
{
oID = tID.getText().toString();
tID.setText(oID+"ddf"+"\n");
oName = tName.getText().toString();
clist = -1;
}
}
}
list.xml
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/VScroll"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="3" >
<TextView
android:id="#+id/tID"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text=" " />
<TextView
android:id="#+id/tName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text=" " />
<TextView
android:id="#+id/tWorld"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text=" " />
</LinearLayout>
</ScrollView>
I know this is probably really simple but looking online doesn't answer it...
why does this crash upon getting to here?:
I know this is probably really simple but looking online doesn't answer it...
why does this crash upon getting to here?:
while (clist != -1)
{
oID = tID.getText().toString();
tID.setText(oID+"ddf"+"\n");
oName = tName.getText().toString();
clist = -1;
}
Edit*
Search() is an onClick button in ps.xml while the textview are in list.xml
Inside your onCreate() method:
change from setContentView(R.layout.ps); to setContentView(R.layout.list); because you are using list.xml as your main layout.
and delete this line setContentView(R.layout.list); inside your Search() method:
public void Search(View view) {
int clist = -2;
String oID = "";
String oName = "";
String oWorld = "";
// Delete this line setContentView(R.layout.list);
while (clist != -1)
{
oID = tID.getText().toString();
tID.setText(oID+"ddf"+"\n");
oName = tName.getText().toString();
clist = -1;
}
}
I would like to display a two textView in my ListView depending on the database value.
But in result nothing is displayed (error)
This is my code:
public class ListbookActivity extends ListActivity implements OnQueryTextListener{
private DBHelper database;
private Intent intent;
private ListView listav;
private SimpleCursorAdapter adapter;
private String strclickmenu;
private Cursor cursor;
private Toast t;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
String[] from = new String[] { "titolo", "autore" };
int[] to = new int[] { R.id.name, R.id.surname};
database = new DBHelper(getApplicationContext());
SQLiteDatabase db = database.getReadableDatabase();
//query
cursor = db.query("libreria", null, null, null, null, null, "titolo", null);
cursor.moveToFirst();
listav = (ListView) findViewById(R.id.list);
adapter = new SimpleCursorAdapter(this,R.layout.list_row, cursor,from,to,0);
adapter.setViewBinder(new SimpleCursorAdapter.ViewBinder() {
#Override
public boolean setViewValue(View view, Cursor cursor, int columnIndex) {
if (view.getId() == R.id.name) {
String userFullName = cursor.getString(cursor.getColumnIndex("titolo"));
TextView tit = (TextView)view;
tit.setText(userFullName);
return true;
} else if (view.getId() == R.id.surname) {
String userEmail = cursor.getString(cursor.getColumnIndex("titolo"));
TextView aut = (TextView)view;
aut.setText(userEmail);
return true;
} else {
return false;
}
}
});
listav.setAdapter(adapter);
list_row.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="horizontal" >
<TextView
android:id="#+id/name"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1.51"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/surname"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1.51"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>
activity_listbook.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" >
<ListView android:id="#+id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:smoothScrollbar="false"
android:fadingEdge="none"/>
</LinearLayout>
This is the error:
Unable to start activity componentInfo{com.example.mybooks.ListBookActivity} : Java.lang.nullPointerException
View Database XML file:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#drawable/wood_bg" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="10dp"
android:layout_marginTop="10dp"
android:text="Daily Fruit Log"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textStyle="bold"/>
<TableLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TableRow>
<TextView
android:layout_width="110dp"
android:layout_height="fill_parent"
android:text="Name of fruit"
android:layout_weight="1"
android:textStyle="bold"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:text="No Of Fruit"
android:layout_weight="1"
android:textStyle="bold"/>
<TextView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="Total Calories"
android:layout_weight="1"
android:textStyle="bold"/>
</TableRow>
</TableLayout>
<TableLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp">
<TableRow>
<TextView
android:id="#+id/view"
android:layout_width="110dp"
android:layout_height="wrap_content"
android:text="food"
android:layout_weight="1" />
<TextView
android:id="#+id/view1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="1"
android:layout_weight="1"/>
<TextView
android:id="#+id/view2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="20"
android:layout_weight="1"/>
</TableRow>
</TableLayout>
<Button
android:id="#+id/bdelete"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Clear Log"
android:layout_gravity="center"
android:layout_marginTop="30dp" />
Java class of View Database page:
public class FruitLog extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.fruitlog);
TextView tv = (TextView) findViewById(R.id.view);
TextView tv1 = (TextView) findViewById(R.id.view1);
TextView tv2 = (TextView) findViewById(R.id.view2);
FruitDB info = new FruitDB(this);
info.open();
String data = info.getName();
String data1 = info.getNum();
String data2 = info.getCal();
info.close();
tv.setText(data);
tv1.setText(data1);
tv2.setText(data2);
Button save = (Button) findViewById(R.id.bdelete);
save.setTextColor(Color.BLUE);
save.setOnClickListener(new View.OnClickListener(){
public void onClick(View v) {
// TODO Auto-generated method stub
FruitDB info = new FruitDB(FruitLog.this);
info.open();
info.deleteAll();
info.close();
}
});
}
I have edited the code, now I can delete all the data in my page, but the issue is that, I have to navigate back and enter this FruitLog page to see the changes (all rows deleted).
I want to see a immediate result when the user click 'Clear Log' Button without navigating back and front.
This method in your db class:
public boolean deleteAll() {
// Returns true if number of deleted rows is larger than 0;
return mDb.delete(DATABASE_TABLE, null, 1) > 0;
}
In the onClickListener:
public void onClick(View v) {
FruitDB db = new FruitDB(YourClass.this);
db.open();
db.deleteAll();
db.close();
}
To delete entire table:
db.delete(DATABASE_TABLE, null, null);
To delete particular records in a table:
db.delete(DATABASE_TABLE, whereCondition, null);
for eg:
db.delete(DATABASE_TABLE, "KEY_NAME='mango'", null);
Button save = (Button) findViewById(R.id.bdelete);
save.setTextColor(Color.BLUE);
save.setOnClickListener(new View.OnClickListener(){
public void onClick(View v) {
// TODO Auto-generated method stub
DbHelper myDbHelper =new DbHelper(Activity.this);
try{
myDbHelper.open();
myDbHelper.delete();
}catch(Exception e){
e.printStackTrace();
}finally{
myDbHelper.close();
}
}
});
create a method in your DBHelper class
public void delete() {
ourDatabase.execSQL("delete from "+ DATABASE_TABLE);
ourDatabase.execSQL("UPDATE sqlite_sequence set "+ KEY_ROWID + " =0 where name= '"+DATABASE_TABLE+"'");
}
It will delete all records
public void deleteAll() {
final SQLiteDatabase db = getWritableDatabase();
db.delete(DATABASE_TABLE, null, null);
db.close();
}
Move this code to save.setOnClickListener(new View.OnClickListener(){..} after deleting
or move it to onResume()
FruitDB info = new FruitDB(this);
info.open();
String data = info.getName();
String data1 = info.getNum();
String data2 = info.getCal();
info.close();
tv.setText(data);
tv1.setText(data1);
tv2.setText(data2);
Hi I have a AutoCompleteTextView which works fine on my Nexus1. When deploying the code on a Samsung Apollo i5801 the list doesn't display correctly. The data is in the list as I can scroll a little (see pics below).
Here is my CursorAdapter
class VenueSuggestionLitsAdpater extends CursorAdapter implements
Filterable {
private HiTechDatabaseAdapter database;
public VenueSuggestionLitsAdpater(Context context, Cursor c) {
super(context, c);
// database = HiTechDatabaseAdapter.getInstance(JobActivity.this);
// TODO Auto-generated constructor stub
}
#Override
public void bindView(View view, Context context, Cursor cursor) {
int name = cursor.getColumnIndex("name");
int postcode = cursor.getColumnIndex("postcode");
String str = cursor.getString(name) + " - "
+ cursor.getString(postcode);
((TextView) view).setText(str);
}
#Override
public View newView(Context context, Cursor cursor, ViewGroup parent) {
final LayoutInflater inflater = LayoutInflater.from(context);
final TextView view = (TextView) inflater.inflate(
android.R.layout.simple_dropdown_item_1line, parent, false);
int name = cursor.getColumnIndex("name");
int postcode = cursor.getColumnIndex("postcode");
String str = cursor.getString(name) + " - "
+ cursor.getString(postcode);
view.setText(str);
return view;
}
#Override
public CharSequence convertToString(Cursor cursor) {
int columnIndex = cursor.getColumnIndexOrThrow("name");
String name = cursor.getString(columnIndex);
// Log.d("Debug","Convert To String....");
return name;
}
#Override
public Cursor runQueryOnBackgroundThread(CharSequence constraint) {
if (constraint == null) {
Cursor suggestions = HiTechDatabaseAdapter.getInstance(
JobActivity.this).queryVenueName(
HiTechDatabaseAdapter.TABLE_VENUES,
new String[] { "_id", "name", "address", "postcode","venueID" },
"");
return suggestions;
}
Cursor suggestions = HiTechDatabaseAdapter.getInstance(
JobActivity.this).queryVenueName(
HiTechDatabaseAdapter.TABLE_VENUES,
new String[] { "_id", "name", "address", "postcode","venueID" },
constraint.toString());
return suggestions;
}
}
And how I apply my adapter to my AutoCompleteTextView
VenueSuggestionLitsAdpater suggestionsAdapter = new VenueSuggestionLitsAdpater(
JobActivity.this, suggestions);
venuNameSearch.setAdapter(suggestionsAdapter);
Finally my XML layout
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="10px">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/venuetextlabel"
android:text="Venue:"
/>
<AutoCompleteTextView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/venuesearch"
android:editable="true"/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/textcampaign"
android:text="Campaign:"
/>
<Spinner
android:layout_width="fill_parent"
android:layout_height="60px"
android:id="#+id/campaign"
android:drawSelectorOnTop="true"
android:prompt="#string/campaign"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/textgender"
android:text="Gender:"
/>
<Spinner
android:layout_width="fill_parent"
android:layout_height="60px"
android:id="#+id/gender"
android:drawSelectorOnTop="true"
android:prompt="#string/gender"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/textreason"
android:text="Reason:"/>
<Spinner
android:layout_width="fill_parent"
android:layout_height="60px"
android:id="#+id/reason"
android:drawSelectorOnTop="true"
android:prompt="#string/reason"
/>
<EditText
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/address_line_1"
android:hint="Address Line 1"
android:editable="false"
/>
<EditText
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/address_postcode"
android:hint="Postcode"
android:editable="false"
/>
<Gallery
android:id="#+id/gallery"
android:layout_marginTop="10px"
android:spacing="10px"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<Button
android:layout_width="200px"
android:layout_height="60px"
android:id="#+id/submit"
android:text="Submit"
android:textSize="20sp"
android:textStyle="bold"
android:layout_gravity="center_horizontal"
android:layout_marginTop="10px"
/>
</LinearLayout>
Any help would be much appreciated.
Cheers