load image from network:)
public class Main extends ListActivity {
private static final String LOG_TAG = "SharePath";
List<Map<String, Object>> list;
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
// requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.main);
list = new ArrayList<Map<String, Object>>();
int index = 1;
// addItem(list, index++ + ". test", activityIntent(
// "org.yexing.android.sharepath",
// "org.yexing.android.sharepath.ChooseBuddy"));
// addItem(list, index++ + ". Ask for Directions", activityIntent(
// "org.yexing.android.sharepath",
// "org.yexing.android.sharepath.Request"));
addItem(list, index++ + ". Ask or Record", activityIntent(
"org.yexing.android.sharepath",
"org.yexing.android.sharepath.SharePathMap"));
addItem(list, index++ + ". Inbox", activityIntent(
"org.yexing.android.sharepath",
"org.yexing.android.sharepath.Inbox"));
// addItem(list, index++ + ". Outbox", activityIntent(
// "org.yexing.android.sharepath",
// "org.yexing.android.sharepath.Outbox"));
// addItem(list, index++ + ". Sent Request", activityIntent(
// "org.yexing.android.sharepath",
// "org.yexing.android.sharepath.Sent"));
addItem(list, index++ + ". My Maps", activityIntent(
"org.yexing.android.sharepath",
"org.yexing.android.sharepath.MyMaps"));
addItem(list, index++ + ". My Buddies", activityIntent(
"org.yexing.android.sharepath",
"org.yexing.android.sharepath.Buddy"));
setListAdapter(new ImageSimpleAdapter(this, list,
R.layout.main_list, new String[] { "title" },
new int[] { android.R.id.text1 }));
// 模拟bootup的按钮
// Button btnBoot = (Button) findViewById(R.id.boot);
// btnBoot.setOnClickListener(new View.OnClickListener() {
//
// public void onClick(View v) {
// Intent intent = new
Intent(Intent.BOOT_COMPLETED_ACTION);
// broadcastIntent(intent);
// }
// });
}
@SuppressWarnings("unchecked")
@Override
protected void onListItemClick(ListView l, View v, int position, long
id) {
Map map = (Map) l.obtainItem(position);
Intent intent = (Intent) map.get("intent");
startActivity(intent);
}
@SuppressWarnings("unchecked")
protected void addItem(List<Map<String, Object>> data, String name,
Intent intent) {
Map<String, Object> temp = new HashMap<String, Object>();
temp.put("title", name);
temp.put("intent", intent);
data.add(temp);
}
protected Intent activityIntent(String pkg, String componentName) {
Intent result = new Intent();
result.setClassName(pkg, componentName);
return result;
}
class ImageSimpleAdapter extends SimpleAdapter {
public ImageSimpleAdapter(Context context, List data, int
resource,
String[] from, int[] to) {
super(context, data, resource, from, to);
// TODO Auto-generated constructor stub
}
@Override
public int getCount() {
// TODO Auto-generated method stub
return list.size();
}
@Override
public View getView(int position, View convertView, ViewGroup
parent) {
// TODO Auto-generated method stub
if(convertView == null) {
ViewInflate inflate = (ViewInflate)
getSystemService(Context.INFLATE_SERVICE);
convertView = inflate.inflate(R.layout.main_list, null,
null);
TextView tv =
(TextView)convertView.findViewById(R.id.text1);
tv.setText((String)list.get(position).get("title"));
ImageView iv =
(ImageView)convertView.findViewById(R.id.image);
// iv.setImageResource(R.drawable.badge);
Uri uri = Uri.parse("http://www.yexing.org/image.axd?
picture=browse.png");
// iv.setImageURI(uri);
// Drawable drawable =
Drawable.createFromPath(uri.getPath());
try {
URL url = new
URL("http://www.yexing.org/image.axd?
picture=browse.png");
InputStream is = url.openStream();
Drawable drawable =
Drawable.createFromStream(is, "none");
iv.setImageDrawable(drawable);
} catch(Exception e) {
Log.e(LOG_TAG, "load image error! \n" +
e.toString());
}
}
return convertView; //super.getView(position,
convertView, parent);
}
}
}
On Apr 1, 7:56 am, dsrekab <[EMAIL PROTECTED]> wrote:
> I want to add images to a map that represent stored points on the map.
> I can add an image if the image is stored in the r.drawable folder,
> however, I would like the user to be able to load an image when they
> store the point. For instance, if they stored a pointer to their work,
> they may add an image of the company logo or something like that.
>
> My initial thought was to store the uploaded image in the database in
> base64 format. I then have a webpage the decodes the stored image and
> displays it. However, I am not sure how to request the image from the
> Android client, then show it on the map.
>
> Does anyone have any ideas on how to get the image from the web
> server, then display it on the map? Or possibly another way to
> accomplish this task?
>
> Thanks in Advance for any help anyone can offer.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---