Android :: Simple Adapter - Text - Image In Spinner - Java

Sep 10, 2010

I've got a little problem...Well, let me first state what I'm trying to accomplish. I had a spinner that pulls strings out of a stored array.

Like so, you dont need to read it though:

CODE:...........................

So far I've got a custom SimpleAdapter.

Here is the Problem!! : the text comes up but not the image. Heres the code:


CODE:........

I plan to use a switch statement to set different images to each name. however i stopped here until i can get any image to show. How i'm calling

CODE:........................

Android :: Simple Adapter - Text - Image in spinner - Java


Android :: Photo URI Of Contact Image - Using With Simple Cursor Adapter

Apr 8, 2010

I want to write a short app for getting some info from contacts, the first list screen I have should display the user Image (or an Image from resources if no such image exists) an the user display name. The problem is I don't seem to find a query that will provide me with the display name and a user id And the image URI in the same query. Moreover I'm aware of the fact that if the user has no image and the URI is empty or null i will most likely to get an exception while the adapter calls setViewImage(). Is there a simple way around it or should I override the setViewImage() or bindView() methods?

Also about the query, any chance I can make a single query for contact URI, _ID, contact_id and display name? my current queries: To get the contacts:
private Cursor getContacts() { Uri uri = ContactsContract.Data.CONTENT_URI;
String[] projection = new String[] ContactsContract.Data._ID,ContactsContract.Data.CONTACT_ID,
ContactsContract.Data.DISPLAY_NAME };
String selection = ContactsContract.Data.MIMETYPE + " = ?";
String[] selectionArgs = {ContactsContract.CommonDataKinds.StructuredPostal.CONTENT_ITEM_TYPE};
String sortOrder = ContactsContract.Contacts.DISPLAY_NAME + " ASC";
return managedQuery(uri, projection, selection, selectionArgs, sortOrder); }

If I have a contact id and want the image:
int _id = m_cursor.getColumnIndex(ContactsContract.Contacts._ID);
//try to retrieve the photo, if exists.
Uri photoUri = ContentUris.withAppendedId(ContactsContract.Contacts.CONTENT_URI,
m_cursor.getLong(_id)); InputStream is = ContactsContract.Contacts.openContactPhotoInputStream(m_context.getContentResolver(), photoUri);
Here I get from a cursor with _ID column the id and then creating the uri, I know I can get a row number but I'm not familiar enough with contentProvider to know how to join tables to get it all in one query (if even possible).

View 2 Replies View Related

Android :: Simple Cursor Adapter - List View - Binded To XML Document With Three Text Views

Mar 18, 2009

I have table with 3 columns which is binded to an XML document with three text views.

CODE:........

Depending on the value store in the third column, I want to change the text color in R.id.c. How should, I go about with this.

This is what I have so far :

COD:...............

View 3 Replies View Related

How To Draw Image Or Edit Simple Lines In Text Box

Jan 8, 2013

I am wondering if there is a way to draw an image, or edit simple lines in a text box. The entire screen is a textView/ect and i would like to be able to write a sentence then draw an image and write again. By draw i think i would use the Canvas, so basically is there a way to include a canvas in a text view?

Evernote does do this, but to edit an image/draw you need to open another app "Skitch", my goal is to try and do this without any extra apps.

For example:

Hello

(canvas/editable graphical items)

World

View 3 Replies View Related

Android : Binded Spinner Widget - Cursor Adapter?

Aug 24, 2009

I successfully binded a spinner widget to a simple cursor adapter, but I started having problems when I tried to add a new item to the table which feeds the spinner by clicking an "add new item" button. The idea was to launch a new activity which returns the rowid of the just added element, and use it to set the new position.

What I basically did is to implement something like:

break; in the "onActivityResult" method, the rowid has the correct value but setSelection has no effect. I also tried to force the argument to some other values, but still with no result. If I call it in the onCreate method, it works beautifully. Moreover, I am still not sure that setSelection is the right method to call, since its arg is named "position" in the doc, while I am passing an "id".

View 2 Replies View Related

Android :: How To Use Simple Cursor Adapter To Include Button?

Jun 9, 2009

I have read the Gallery2.java example, which show how to map a Column's value to an element in the view I want to create (in this case, it maps 'NAME' to text1 element0. But what if I have a Button in my view, how can I know which Person is being clicked? or how can I query the person's info when a button in the new is clicked?

From the Gallery2.java example:
SpinnerAdapter adapter = new SimpleCursorAdapter(this,
// Use a template that displays a text view
android.R.layout.simple_gallery_item,
// Give the cursor to the list adatper c,
// Map the NAME column in the people database to...
new String[] {People.NAME},
// The "text1" view defined in the XML template
new int[] { android.R.id.text1 });
Gallery g = (Gallery) findViewById(R.id.gallery);

View 2 Replies View Related

Android :: Simple Cursor Adapter - List View

Jun 9, 2010

I have table with 3 columns which is binded to an XML document with three text views.

CODE:........

Depending on the value store in the third column, I have to decide whether i should display this row or not

How should, I go about with this.

This is what I have so far :

CODE:...............

View 2 Replies View Related

Android : Want To Display As List View - Using Simple Adapter

Jul 12, 2010

I am calling one webservice.Result of webservice I am storing in an Array list. Result of webservice I want to display as list view. For ListView I am using SimpleAdapter. and SimpleAdapter is something like this:- SimpleAdapter adapter = new SimpleAdapter(this,hashmap, layout, from, to);

I am not able to put array list into hashmap. Is there anyway to do this?

View 2 Replies View Related

Android : Implementation Of A Simple AdapterView Where Items Comes From An Basic Adapter

Apr 1, 2010

I'm trying to make (for learning purposes) my own implementation of a simple AdapterView where items comes from an basic Adapter (ImageAdapter from sdk samples).

Actual code is like this:

public class MyAdapterView extends AdapterView<ImageAdapter> implements AdapterView.OnItemClickListener{
private ImageAdapter mAdapter;
public MyAdapterView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
initThings();}
private void initThings(){
setOnItemClickListener(this);}
@Overridepublic ImageAdapter getAdapter() {
// TODO Auto-generated method stubreturn mAdapter;}
@Overridepublic void setAdapter(ImageAdapter adapter) {
// TODO Auto-generated method stub
mAdapter=adapter;
requestLayout();}
View obtainView(int position) {
View child = mAdapter.getView(position, null, this);
return child;} code...

This isn't a coding masterpiece, it just displays a pseudo-listview with pictures. I know i could've used ListView, GridView, Spinner, etc. but i'm relative new to android and i'm trying to figure out some things on it. Well, the question here is Why is my onItemClick not firing?

Using the same ImageAdapter with a GridView, everything works ok, but when i use with above class, i get nothing. Inside AdapterView.java there is code for those click, longclick, etc events... so why can't i just fire them? Maybe i'm misunderstanding basic things on how AdapterView works? Should I extend other base classes instead? And why? Hoping to find more experienced guidance on here, thanks in advance.

View 2 Replies View Related

General :: Simple Cable To USB Adapter Will Work On Asus Transformer For Connecting To Internet

Mar 5, 2012

Few Asus Transformer Questions. I have been looking for something I can browse the internet with, watch video, and take notes in class all while having the capabilities of a tablet. My girlfriend works nights at a sleep lab and has an extremely terrible wifi connection at her work. The only way for her to connect to the internet is via cable. I'm thinking that the Transformer (with dock) is our best option but I was wondering if a simple cable to USB adapter will work on a Transformer for connecting to the internet?

View 4 Replies View Related

Android :: Simple Shape Recognition Libraries For Java

Mar 16, 2010

I am working on a on-screen keyboard for Android, and I need to recognize starting points, turning points and end points of lines drawn by the user on the keyboard. A simple straightening function would be nice, as it is difficult to draw a perfectly straight line even with a stylus, not to mention finger-only touchscreens today.What I am trying to write is something like Swype. Any good libraries that I can use or make reference to?

View 1 Replies View Related

Android :: Simple Converting Java.util.Calendar To Time

Nov 12, 2010

I'm creating a android.text.format.Time Object from a java.util.Calendar Instance, and I read it out field by field.

View 1 Replies View Related

Android :: Develop Using Libraries In Simple Java Project - Without Using Dalvik And Such

Oct 9, 2010

As I am very pissed off of using the emulator to develop any Java class, I thought of setting up a project in Eclipse and instead of the usual JRE I linked to the Android.jar (version 2.1) that usually the Android projects link to. I don't mean to use this to develop Layouts or other specific platform things, I was just trying to create a class that uses HttpClient.

It miserably crashes like this.

CODE:.............

I mean I'd like to develop libraries (and test them) so that when I go to the emulator I don't have to deal with them. Is there a good way to do this? This seems not to work for some reason.

View 1 Replies View Related

Android :: Use HTTP Post Method Or Simple Java Socket Program

Mar 20, 2010

Could someone please suggest me a good/efficient way to communicate with the server. I could think of two options 1) Use http post methods to send data to a php script at the server which would later call the google api's written in another java program (jar)or use php to use google api's (if its possible) to find nearby restaurants and send the list back to client. 2) Use simple java socket programming. The server has a jar file that supports multi threading and it does the job of finding restaurants and sending the list.

View 4 Replies View Related

Android :: Make Adapter Class To Choose .Java File Depending On Firmware Version

Sep 1, 2010

What I did was create two .java files. One that can compile and run on a 1.5 phone (SDK3) and then one that works on 2.0(SDK5) So for this example i'll call the 1.5 file ExampleOld and the new one Example. I was wondering if i just made activity like this if it would work sort of like a "portal" and pick the activity to load depending on the SDK so there is no crash or compile errors. Are there any changes I should make to my code? Maybe anyone out there that's had to do this before.

CODE:.................................

View 2 Replies View Related

Android :: Display A Dialog In Non-Activity - Simple Java - Class By Passing Parameters

Jun 23, 2010

I am trying to display a dialog box in a simple Java class that is called from my main Activity but not successful. Please help me to figure it out.

I am passing the required values as parametrs.

I have two class: class MainActivity extends Activity :: Main *starting point *of Application class ShowMyDialog :: a simple java program In which I *generate an URl* and *display a dialog with WebView*.

I am passing the Acitivity from my MainActivity to this class as a parameter in function.

But I am *unable to call* the onCreateDialog method that I have *defined in the simple java class.

However, If I define the *onCreateDialog method in MainActivity, I am able to display it successfully.

What Should I pass as Parameter to the non Activity class from MainActivity class so that I am able to display the dialog as defined by showdialog method in JAVA class ???*

My steps of source code is as follow:

code:.........................

View 3 Replies View Related

Get Drawable Name From Image Adapter?

Oct 20, 2011

Im making an app in which the user selects an image and then gets redirected to a new screen in which the drawable name is displayed.

This is the code triggered when the user click an image:

Code:
public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
Intent tabsIntent = new Intent();
tabsIntent.setClassName("com.budisha.app", "com.budisha.app.TabClassActivity");
tabsIntent.putExtra("pic_name", position); //sends picture position
startActivity(tabsIntent);
}

This sends the new activity the drawable position. But i need to get the drawable name.

View 2 Replies View Related

HTC Desire :: Simple Text Editor To Create / Edit Text Files From SD Card?

May 12, 2010

I thought this would be easy to find:

A text editor that can create/edit text files from the SD card.

i.e. Windows Notepad on the Desire?

View 4 Replies View Related

Android :: Show Spinner Wheel Instead Of Image While Downloading Source

Oct 17, 2010

I am going to create a gallery view where the user shall switch between different pictures of products. On some of them is going to be a label like "sale" and a short discription. On startup I want to display a loading animation at that place until the product photo is downloaded.

Use layer list or state list for one product photo?
Could you please show me, how to set that up?
How to make that spinner spin?
How to turn it on or off (how to access the layer list through code)?

By the way, is "spinner" the best word for this? It seems to stand for several things. Feel free to edit this question, if I didn't hit the right words.

View 1 Replies View Related

Android :: How To Implement Position In Image Adapter To Return Customized View?

Jul 12, 2010

Sample code there is a method getitem(position) in the class of image adapter which returns null for the sample example. However, this method is important and is supposed to return the corresponding data item of the image adapter. For example the image adapter could generate a series of customized image views by magically calling the getview method. How could we implement the getitem(position) method under this case to help us gain access to these customized image views?

View 2 Replies View Related

Android :: Android (Java) Simple Send And Receive With Server

Jun 11, 2009

I'm writing an Android App and I'm looking for the fastest (In terms of setup) way for me to send data to a server and receive information back on request. We're talking basic stuff. I have a log file which tells me how a user is using my application (In beta, I wouldn't runin a user experience by constantly logging usually) and I want to communicate that to my server (That I haven't setup).

I don't need security, I don't need high throughput or concurrent connections (I have 3 phones to play with) but I do need to set it up fast! I remember back in the day that setting up XAMPP was particularly brainless, then maybe I could use PHP to send the file from the phone to the Server? The Server would ideally be able to respond to a GET which would allow me to send back some SQL statements which ultimately affect the UI. (It's meant to adapt the presented options depending on those most commonly used).

So there you have it, I used PHP about 4 years ago and will go down that route if it's the best but if there's some kind of new fangled port open closing binary streaming singing and dancing method that has superseeded that option I would love to know. This tutorial seems useful but I don't really need object serialization, just text files back and forth, compressed naturally. Android comes with the Apache HTTP Client 4.0 built in as well as java.net.URL and java.net.HttpUrlConnection, I'd rather not add too much bult to my App with third party libraries.

View 5 Replies View Related

Android :: Use Droid Spinner With Text And Value?

May 4, 2010

I want to use Android spinner with following data.
Spinner will display only text data not code....

i have stored above comma separated data in same activity class (Hard coded form) now if user selects "a" from the dropdown then it should get its code rather then text.

can any one guide me how to achieve this?

View 1 Replies View Related

Android :: Simple Way To Align Text On Tab?

Sep 19, 2009

I think I already know the answer to these, but I'm going to ask anway:

1) Is there a straightforward way to set the background color of a tab in its unselected state?

2) Is there a simple way to align the text on a tab?

View 2 Replies View Related

Android :: How To Decrease Text Size Of A Spinner?

Jul 25, 2010

How can I decrease the font size of my spinner? I have reduced the spinner size to 35 pix because of which my text gets cut in half. How do i do that? Also I dont want anything to be selected beforehand. Default text should be "select some value".

View 1 Replies View Related

Android :: Way To Create Spinner With Editable Text?

Feb 10, 2009

I would like to create a spinner where a user can edit the text for each drop-down entry. For example, I have a spinner for users, with pre-populated names: User 1, User 2, and User 3. I want the user to be able to edit these names to their liking.

View 2 Replies View Related

Android :: Selecting From Spinner & Sending As Text Sms

Aug 30, 2010

I have two different activities in my project.I intend to pass data from one activity to another. (As per user interface, I select an item from The spinner in one activity and send it as text msg.) The coding for text msg is done in another activity i.e the second activity.I m successfully able to select the desired item from the Spinner but am not able to pass it as text message. to select the item from first activity. It functions well BUT HOW DO I CAPTURE/RECEIVE THIS In the second activity that will send it as a text message.

View 3 Replies View Related

Android :: Way To Change Text Style Of A Spinner

Jul 8, 2010

I'm creating a spinner in my layout xml files and setting an string array to this spinner.
If I change the textstyle of the spinner the text is not affected by the changes.

I read in the googlegroups that a spinner has no text and therefore the textstyle can not be changed and I have to change the style of the textview that is shown in the spinner. But how can I do that. Preferably in my xml file.

View 1 Replies View Related

Android : Way To Customize Text On Spinner Control?

Nov 5, 2010

I've seen some answers to questions about how to specify a custom layout for a spinner's pop-up list, but what I want to do is to customize the text on the Spinner control itself, such the "setText..." methods that you can call for a Button (TextView subclass). Is there any way to do this? What I'm trying to do is to make my own Spinner design as I have for some of the other controls so it takes up less space and matches the general look of my app.

View 1 Replies View Related

Android :: Adding Button To Efficient Adapter Which Has Icon And Text?

Apr 19, 2010

I want to create a layout in such a way that on top edittext and button should be there in one row. The search text I enter in editext and click on search button. Then I want to display a custom list view where each row contains image and text.(As per the API demos example list14 I have tried). But when I run the application, button and edittext are being added to each row (i.e., Each row contains a image, text, editext, button.

Below is my xml file:
<!--
<FrameLayout android:layout_width="wrap_content"
android:layout_height="0dip" android:layout_weight="1"></FrameLayout>
-->
<ImageView android:id="@+id/icon" android:layout_width="48dip"
android:layout_height="48dip" />
<TextView android:id="@+id/text" android:layout_gravity="center_vertical"
android:layout_width="0dip" android:layout_weight="1.0"
android:layout_height="wrap_content" />
<!--
<EditText android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="@+id/prdsearchtb"
android:text="@string/tb_prd_search_lbl"></EditText>
-->
<!--
<TableLayout android:id="@+id/TableLayout01"
android:layout_width="fill_parent"
android:layout_height="wrap_content"> <TableRow>
-->
<Button android:id="@+id/prdsrcbutton" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="@string/btn_lbl_prd_search"
android:layout_x="2px" android:layout_y="410px"></Button>
<!-- </TableRow>
</TableLayout>
-->
and Java File:
/**
*
*/
package org.techdata.activity;

import android.app.AlertDialog;
import android.app.ListActivity;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;

/**
* @author jayanthg
*
*/
public class ProductSearch extends ListActivity {
private static class ProductSearchAdapter extends BaseAdapter {
private LayoutInflater mInflater;
private Bitmap mIcon1; private Bitmap mIcon2;
public ProductSearchAdapter(Context context) {
mInflater = LayoutInflater.from(context);
// Icons bound to the rows.
mIcon1 = BitmapFactory.decodeResource(context.getResources(),
R.drawable.icon48x48_1);
mIcon2 = BitmapFactory.decodeResource(context.getResources(),
R.drawable.icon48x48_2);
} @Override public int getCount() { return DATA.length;
} @Override public Object getItem(int position) { return position;
} @Override public long getItemId(int position) { return position;
} @Override public View getView(final int position, View convertView,
ViewGroup parent) { ViewHolder holder; Button btn=null;
if (convertView == null) { convertView = mInflater.inflate(R.layout.productsearch, null);
// Creates a ViewHolder and store references to the two children
// views // we want to bind data to. holder = new ViewHolder();
holder.text = (TextView) convertView.findViewById(R.id.text);
holder.icon = (ImageView) convertView.findViewById(R.id.icon);
btn=(Button)convertView.findViewById(R.id.prdsrcbutton);
convertView.setTag(holder);
} else {
// Get the ViewHolder back to get fast access to the TextView
// and the ImageView. holder = (ViewHolder) convertView.getTag();
}
// Bind the data efficiently with the holder.
holder.text.setText(DATA[position]);
holder.icon.setImageBitmap((position & 1) == 1 ? mIcon1 : mIcon2);
holder.icon.setOnClickListener(new View.OnClickListener() {
@Override public void onClick(View v) {
Log.i("image", " u clicked on icon Position" + position);
} } );
holder.text.setOnClickListener(new View.OnClickListener() {
@Override public void onClick(View v) {
Log.i("Text", " u clicked on text Position" + position);
} } );
btn.setOnClickListener(new View.OnClickListener() {
@Override public void onClick(View v) {
Log.i("Button","U clicked on button");
} } ); return convertView;
} static class ViewHolder { TextView text; ImageView icon;
} private static final String[] DATA = ListView product_search_list;
Button srch_btn;
EditText srch_text; @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setListAdapter(new ProductSearchAdapter(this));
// setContentView(R.layout.productsearch);
// getListView().setEmptyView(findViewById(R.id.text));
// srch_text = (EditText)findViewById(R.id.prdsearchtb);
// srch_btn = (Button) findViewById(R.id.prdsearchtb);
// srch_btn.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View v) {
// callProductSearchAdapter();
// }
// });
} void callProductSearchAdapter() { setListAdapter(new ProductSearchAdapter(this));
} private void createDialog(String title, String text, final Intent i) {
if (i == null) { AlertDialog ad = new AlertDialog.Builder(this).setIcon(
R.drawable.alert_dialog_icon).setPositiveButton("Ok", null)
.setTitle(title).setMessage(text).create();
ad.show();
} } }

View 2 Replies View Related

Android :: App Force Close Whenever Getting Text From Spinner / Resolve This Error?

Jul 21, 2010

Code...

so I'm using this coding lines to get the text from my spinner and pass it on to another Java file. But the application keeps giving me a force close whenever I do this.

How can I resolve this error?

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved