Loading

Friday, September 4, 2009

HelloGallery, get and display the path of selected picture

Further extend from previouse exercise, HelloGallery, read picture files from SD, using File ArrayList, and File type checking for HelloGallery, the path of the selected picture will be displayed using Toast.



It involve little bit modification on onItemClick(AdapterView parent, View v, int position, long id), and also onCreate(Bundle savedInstanceState).


public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

Gallery g = (Gallery) findViewById(R.id.gallery);

final List<String> SD = ReadSDCard();
g.setAdapter(new ImageAdapter(this, SD));

g.setOnItemClickListener(new OnItemClickListener()
{
public void onItemClick(AdapterView<?> parent,
View v, int position, long id) {
Toast.makeText(HelloGallery.this,
(CharSequence)SD.get(position),
Toast.LENGTH_LONG).show();
}
});
}

SHARE TWEET

Thank you for reading this article HelloGallery, get and display the path of selected picture With URL https://x-tutorials.blogspot.com/2009/09/hellogallery-get-and-display-path-of.html. Also a time to read the other articles.

0 comments:

Write your comment for this article HelloGallery, get and display the path of selected picture above!