hi m making a filebrowser in android and this is the code for it :
public class FileBrowser extends ListActivity {
private IAppManager imService;
private File currentDir;
private FileArrayAdapter adapter;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Editable usrr = Login.usernameText.getText();
currentDir = new File("/sdcard/");
fill(currentDir);
}
private void fill(File f)
{
File[]dirs = f.listFiles();
this.setTitle(f.getName()+ "'s Chats" );
List<Option>dir = new ArrayList<Option>();
List<Option>fls = new ArrayList<Option>();
try{
for(File ff: dirs)
{
if(ff.isDirectory())
dir.add(new Option(ff.getName(),"Folder",ff.getAbsolutePath()));
else
{
fls.add(new Option(ff.getName(),"File Size: "+ff.length(),ff.getAbsolutePath()));
}
}
}catch(Exception e)
{
}
Collections.sort(dir);
Collections.sort(fls);
dir.addAll(fls);
if(!f.getName().equalsIgnoreCase("sdcard"))
dir.add(0,new Option("..","Parent Directory",f.getParent()));
adapter = new FileArrayAdapter(FileBrowser.this,R.layout.filebrowser,dir);
this.setListAdapter(adapter);
}
#Override
protected void onListItemClick(ListView l, View v, int position, long id) {
// TODO Auto-generated method stub
super.onListItemClick(l, v, position, id);
Option o = adapter.getItem(position);
if(o.getData().equalsIgnoreCase("folder")||o.getData().equalsIgnoreCase("parent directory")){
//v.setBackgroundResource(R.drawable.foler);
currentDir = new File(o.getPath());
fill(currentDir);
}
else
{
onFileClick(o);
}
}
now what i want is to display an icon for the files and the folders.(no other icons, just these 2) i have put an image view in the xml layout but i dont know how to dynamicaly check which list item is file so that it displays a file icon next to it and which one is a folder to display the folder icon.
please help!
You have to customize the FileArrayAdapter.
#Override
public View getView(int position, View convertView, ViewGroup parent) {
View v = convertView;
if (v == null) {
LayoutInflater vi = (LayoutInflater)c.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = vi.inflate(id, null);
}
final Option o = items.get(position);
if (o != null) {
TextView fileName = (TextView) v.findViewById(R.id.FileName);
ImageView fileIcon = (ImageView) v.findViewById(R.id.FileIcon);
if(fileName!=null) {
fileName.setText(o.getName());
if(fileIcon!=null) {
if(o.getData().equalsIgnoreCase("folder")||o.getData().equalsIgnoreCase("parent directory")){
fileIcon.setImageRessource(<FolderIcon>)
} else {
fileIcon.setImageResouce(<FileIcon>)
}
}
}
return v;
}
Related
I have selected set of items from my sdcard folder using multi-selection file-chooser.It returns exactly selected values but the selection highlighted items (using colors) are dynamically changed while scrolling list-view..can anybody tell me how to fix it?
Here i have added my file-chooser class and adapter class..
public class FileChooser extends ListActivity {
private File currentDir;
private FileArrayAdapter adapter;
private Bundle selectedfiles;
String selectedFileAbspath;
ArrayList<String> images_arr = new ArrayList<String>();
boolean is_multiple;
Button file_upload;
Integer val;
Pattern fileExtnPtrn;;
#Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
is_multiple = this.getIntent().getExtras()
.getBoolean("is_multiple", false);
val = this.getIntent().getExtras()
.getInt("value");
if (is_multiple)
{
setContentView(R.layout.file_chooser_list);
file_upload = (Button) findViewById(R.id.file_upload);
file_upload.setOnClickListener(new OnClickListener()
{
#Override
public void onClick(View v)
{
if(selectedfiles.size()!=0)
{
Intent i = new Intent();
i.putExtra("selected_files", selectedfiles);
setResult(RESULT_OK, i);
finish();
}
else
{
showDialog("Please Choose Atleast one File");
}
}
});
}
currentDir = new File("/sdcard/");
selectedfiles = new Bundle();
fill(currentDir);
}
private void fill(File f)
{
File[]dirs = f.listFiles();
this.setTitle("Current Dir: "+f.getName());
List<Item>dir = new ArrayList<Item>();
List<Item>fls = new ArrayList<Item>();
try
{
for(File ff: dirs)
{
Date lastModDate = new Date(ff.lastModified());
DateFormat formater = DateFormat.getDateTimeInstance();
String date_modify = formater.format(lastModDate);
if(ff.isDirectory())
{
File[] fbuf = ff.listFiles();
int buf = 0;
if(fbuf != null)
{
buf = fbuf.length;
}
else buf = 0;
String num_item = String.valueOf(buf);
if(buf == 0)
num_item = num_item + " item";
else
num_item = num_item + " items";
//String formated = lastModDate.toString();
dir.add(new Item(ff.getName(),num_item,date_modify,ff.getAbsolutePath(),"directory_icon"));
}
else
{
fls.add(new Item(ff.getName(),ff.length() + " Byte", date_modify, ff.getAbsolutePath(),"file_icon"));
}
}
}
catch(Exception e)
{
}
Collections.sort(dir);
Collections.sort(fls);
dir.addAll(fls);
if(!f.getName().equalsIgnoreCase("sdcard"))
dir.add(0,new Item("..","Parent Directory","",f.getParent(),"directory_up"));
adapter = new FileArrayAdapter(FileChooser.this,R.layout.file_view,dir);
this.setListAdapter(adapter);
}
#Override
protected void onListItemClick(ListView l, View v, int position, long id) {
// TODO Auto-generated method stub
super.onListItemClick(l, v, position, id);
Item o = adapter.getItem(position);
if(o.getImage().equalsIgnoreCase("directory_icon")||o.getImage().equalsIgnoreCase("directory_up")){
currentDir = new File(o.getPath());
fill(currentDir);
}
else
{
onFileClick(o,v);
}
}
private void onFileClick(Item o,View v)
{
selectedFileAbspath = currentDir.toString() + "/" + o.getName();
RelativeLayout list_item=(RelativeLayout) v;
if(is_multiple)
{
if(validateFileExt(selectedFileAbspath))
{
if (selectedfiles.containsKey(selectedFileAbspath))
{
selectedfiles.remove(selectedFileAbspath);
list_item.setBackgroundColor(getResources().getColor(R.color.white));
}
else
{
selectedfiles.putString(selectedFileAbspath, "1");
list_item.setBackgroundColor(getResources().getColor(R.color.red));
}
}
else
{
showDialog("please select valid image file");
}
}
else
{
if(validateFileExt(selectedFileAbspath))
{
Intent intent = new Intent();
intent.putExtra("GetPath", currentDir.toString());
intent.putExtra("GetFileName", o.getName());
setResult(RESULT_OK, intent);
finish();
}
else
{
Intent intent = new Intent();
setResult(RESULT_CANCELED, intent);
finish();
}
}
}
private boolean validateFileExt(String fileName)
{
fileExtnPtrn = Pattern.compile("([^\\s]+(\\.(?i)(jpg|png))$)");
Matcher mtch = fileExtnPtrn.matcher(fileName);
return mtch.matches();
}
private void showDialog(String string)
{
AlertDialog.Builder alertDialog = new AlertDialog.Builder(this);
alertDialog.setTitle(string);
alertDialog.setPositiveButton("Okay",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
});
alertDialog.show();
}
}
Adapter class
public class FileArrayAdapter extends ArrayAdapter{
private Context c;
private int id;
private List<Item>items;
public FileArrayAdapter(Context context, int textViewResourceId,
List<Item> objects) {
super(context, textViewResourceId, objects);
c = context;
id = textViewResourceId;
items = objects;
}
public Item getItem(int i)
{
return items.get(i);
}
#Override
public View getView(int position, View convertView, ViewGroup parent) {
View v = convertView;
if (v == null) {
LayoutInflater vi = (LayoutInflater)c.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = vi.inflate(id, null);
}
/* create a new view of my layout and inflate it in the row */
//convertView = ( RelativeLayout ) inflater.inflate( resource, null );
final Item o = items.get(position);
if (o != null) {
TextView t1 = (TextView) v.findViewById(R.id.TextView01);
TextView t2 = (TextView) v.findViewById(R.id.TextView02);
TextView t3 = (TextView) v.findViewById(R.id.TextViewDate);
/* Take the ImageView from layout and set the city's image */
ImageView imageCity = (ImageView) v.findViewById(R.id.fd_Icon1);
String uri = "drawable/" + o.getImage();
int imageResource = c.getResources().getIdentifier(uri, null, c.getPackageName());
Drawable image = c.getResources().getDrawable(imageResource);
imageCity.setImageDrawable(image);
if(t1!=null)
t1.setText(o.getName());
if(t2!=null)
t2.setText(o.getData());
if(t3!=null)
t3.setText(o.getDate());
}
return v;
}
}
your problem in getItem method in ListAdapter of List
try this adapter) you must determine all elements of each item in your case)
public class FileArrayAdapter extends ArrayAdapter{
private Context c;
private int id;
private List<Item>items;
public FileArrayAdapter(Context context, int textViewResourceId,
List<Item> objects) {
super(context, textViewResourceId, objects);
c = context;
id = textViewResourceId;
items = objects;
}
public Item getItem(int i)
{
return items.get(i);
}
#Override
public View getView(int position, View convertView, ViewGroup parent) {
View v = convertView;
if (v == null) {
LayoutInflater vi = (LayoutInflater)c.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = vi.inflate(id, null);
}
/* create a new view of my layout and inflate it in the row */
TextView t1 = (TextView) v.findViewById(R.id.TextView01);
TextView t2 = (TextView) v.findViewById(R.id.TextView02);
TextView t3 = (TextView) v.findViewById(R.id.TextViewDate);
/* Take the ImageView from layout and set the city's image */
ImageView imageCity = (ImageView) v.findViewById(R.id.fd_Icon1);
String uri = "drawable/" + o.getImage();
int imageResource = c.getResources().getIdentifier(uri, null, c.getPackageName());
Drawable image = c.getResources().getDrawable(imageResource);
imageCity.setImageDrawable(image);
if(t1!=null)
t1.setText(o.getName());
if(t2!=null)
t2.setText(o.getData());
if(t3!=null)
t3.setText(o.getDate());
return v;
}
}
I have a GridView that loads images from SD card (if present) otherwise some default images. Once images are loaded, the user can select any image cell and take a new picture. When default pictures are loaded in GridView and user takes a picture, the GridView updates and shows the image - but if user clicks the cell again and takes a new picture, then GridView is not updated. Only when I kill the app and restart it, then the new picture appears.
I have tried notifyDataSetChanged() but it doesn't work when image is refreshed.
Here is the code:
public class Fragment1 extends SherlockFragment {
...
private Integer[] mThumbIds = { R.drawable.fr, R.drawable.siderelaxed3,
R.drawable.br, R.drawable.fdbth, R.drawable.bdb, R.drawable.bls,
R.drawable.fls, R.drawable.mm };
private ImageAdapter imageAdapter;
ArrayList<String> f = new ArrayList<String>();// list of file paths
File[] listFile;
ImageLoader imageLoader;
Context context;
boolean needToRefresh = true;
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
context = getActivity();
date = util.getCurrentDate();
Bundle bundle = this.getArguments();
date = bundle.getString(MyCommons.SELECTED_DATE);
}
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View mainView = inflater.inflate(R.layout.picturerecord, container,
false);
getFromSdcard();
Grid = (GridView) mainView
.findViewById(R.id.pictureRecordGrid);
imageAdapter = new ImageAdapter();
Grid.setAdapter(imageAdapter);
imageLoader = new ImageLoader(context, 4);
try {
ourClass = Class
.forName("cameraOpen");
ourIntent = new Intent(context, ourClass);
} catch (ClassNotFoundException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
poseGrid.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View v,
int position, long id) {
startActivityForResult(ourIntent, CAMERA_REQUEST);
poseSelected = position;
}
});
return mainView;
}
public void getFromSdcard() {
f.clear();
for (int i = 0; i < MyCommons.POSES_TO_LOAD.length; i++) {
String pose = MyCommons.pose_names[i];
String path = MyCommons.rootPath + File.separator + pose
+ File.separator + date;
File imgFile = new File(path);
if (imgFile.exists()) {
f.add(path);
Log.d(TAG, "image is present at:" + path);
} else {
f.add("loaddefault");
}
}
}
public class ImageAdapter extends BaseAdapter {
private LayoutInflater mInflater;
public ImageAdapter() {
mInflater = (LayoutInflater) context.getSystemService(
Context.LAYOUT_INFLATER_SERVICE);
}
public int getCount() {
return f.size();
}
public Object getItem(int position) {
return position;
}
public long getItemId(int position) {
return position;
}
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder;
if (needToRefresh == true) {
convertView = null;
Log.d(TAG, "NEEDED REFRESH");
needToRefresh = false;
}
if (convertView == null) {
holder = new ViewHolder();
convertView = mInflater.inflate(R.layout.picturerecorddata,
null);
holder.imageview = (ImageView) convertView
.findViewById(R.id.pictureRecordImage);
holder.textview = (TextView) convertView.findViewById(R.id.pictureRecordText);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
if (f.get(position).equals("loaddefault")) {
DefaultImageLoader defaultImages = new DefaultImageLoader(holder.imageview);
defaultImages.execute(position);
} else {
imageLoader.DisplayImage(f.get(position), holder.imageview, mThumbIds[position], position);
}
holder.textview.setText(MyCommons.pose_names[position]);
return convertView;
}
}
class ViewHolder {
ImageView imageview;
TextView textview;
}
#Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == CAMERA_REQUEST) {
if (resultCode == Activity.RESULT_OK) {
Bitmap photo = BitmapFactory.decodeByteArray(
data.getByteArrayExtra("BitmapImage"), 0,
data.getByteArrayExtra("BitmapImage").length);
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
photo.compress(Bitmap.CompressFormat.JPEG, 100, bytes);
File root = new File(MyCommons.rootPath);
if (!root.exists()) {
root.mkdirs();
Log.d(TAG, "Created Progress pics directory.");
}
String poseName = MyCommons.pose_names[poseSelected];
File pose_dir = new File(root + File.separator + poseName);
if (!pose_dir.exists()) {
pose_dir.mkdirs();
Log.d(TAG, "Created" + pose_dir + " pics directory.");
}
String tempFileName = root + File.separator + poseName + File.separator + date;
File tempFile = new File(tempFileName);
if (tempFile.exists()) {
Log.d(TAG, "File already exist. deleteing it and will write new file:" + tempFileName);
tempFile.delete();
}
util.saveImage(bytes, pose_dir, date);
Log.d(TAG, "image saved. Reloading adapter:\n" + tempFileName);
f.remove(tempFileName);
getFromSdcard();
f.add(poseSelected, tempFileName);
//f.clear();
//f.addAll(f);
imageAdapter.notifyDataSetChanged();
Grid.invalidateViews();
Grid.setAdapter(imageAdapter);
}
}
}
...
}
you need to replace an image in list f with new picture and then call notify, adapter using only items in f for diplaying
I have filled listview with sdcard content but it open in separate list activity. i want to fill my own listview named "list_local_content" in my own activity. here is code..
public class Local_Contents extends ListActivity {
private File currentDir;
private FileArrayAdapter adapter;
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
currentDir = new File("/");
fill(currentDir);
}
private void fill(File f)
{
File[] dirs = f.listFiles();
this.setTitle("Current Dir: "+f.getName());
List<Option>dir = new ArrayList<Option>();
List<Option>files = new ArrayList<Option>();
try{
for(File ff: dirs)
{
if(ff.isDirectory())
dir.add(new Option(ff.getName(),"Folder",ff.getAbsolutePath()));
else
files.add(new Option(ff.getName(),"File Size: "+ff.length(),ff.getAbsolutePath()));
}
}catch(Exception e){
}
Collections.sort(dir);
Collections.sort(files);
dir.addAll(files);
if(!f.getName().equalsIgnoreCase("sdcard"))
dir.add(0,new Option("..","Parent Directory",f.getParent()));
adapter = new FileArrayAdapter(Local_Contents.this,R.layout.listview_filler,dir);
this.setListAdapter(adapter);
}
#Override
protected void onListItemClick(ListView l, View v, int position, long id){
super.onListItemClick(l, v, position, id);
Option o = adapter.getItem(position);
if(o.getData().equalsIgnoreCase("folder")||o.getData().equalsIgnoreCase("parent directory")){
currentDir = new File(o.getPath());
fill(currentDir);
}
else
onFileClick(o);
}
private void onFileClick(Option o)
{
Toast.makeText(this, "File Clicked: "+o.getName(), Toast.LENGTH_SHORT).show();
}
}
and other class which handles filearrayadapter is
public class FileArrayAdapter extends ArrayAdapter{
private Context c;
private int id;
private List<Option>items;
public FileArrayAdapter(Context context, int textViewResourceId, List<Option> objects)
{
super(context, textViewResourceId, objects);
c = context;
id = textViewResourceId;
items = objects;
}
public Option getItem(int i)
{
return items.get(i);
}
#Override
public View getView(int position, View convertView, ViewGroup parent)
{
View v = convertView;
if (v == null)
{
LayoutInflater vi = (LayoutInflater)c.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = vi.inflate(id, null);
}
final Option o = items.get(position);
if(o != null)
{
TextView t1 = (TextView) v.findViewById(R.id.Text_filler1);
TextView t2 = (TextView) v.findViewById(R.id.Text_filler2);
if(t1!=null)
t1.setText(o.getName());
if(t2!=null)
t2.setText(o.getName());
}
return v;
}
}
how do i fill my own listview in my activity with less modifying this code...
for doing this first u need to change what u r extending from listactivity to activity and then find ur listview using findViewById and then on listview obj use method setAdapter and u r done.
In my main layout i have a grid view with some images from resource folder. when i click an image on the main grid view a dialog window pop ups and shows another grid view contains images from sdcard. When i click an image on the grid view on dialog i want to set the clicked image on to the position that is clicked on the main grid view.
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
image.add(R.drawable.split1);
image.add(R.drawable.spli21);
image.add(R.drawable.split22);
image.add(R.drawable.split31);
image.add(R.drawable.split32);
image.add(R.drawable.split33);
image.add(R.drawable.split34);
image.add(R.drawable.split41);
image.add(R.drawable.split42);
image.add(R.drawable.split43);
gv = (GridView) findViewById(R.id.gridView1);
gv.setAdapter(new AppsAdapter(MainActivity.this,image));
gv.setOnItemClickListener(new OnItemClickListener()
{
public void onItemClick(AdapterView<?> parent, View view, int position,long id)
{
// TODO Auto-generated method stub
// Toast.makeText(getBaseContext(),
// "pic" + (position) + " selected",
// Toast.LENGTH_SHORT).show();
//Context context = getApplicationContext();
if(position==0)
{
createdialog(position);
}
}
});
}
public void createdialog(int pos8)
{
pos1 = pos8;
System.out.println("Position->"+pos1);
dialog = new Dialog(this);
dialog.setContentView(R.layout.content);
dialog.setTitle("Select Contents !!");
dirs.clear();
listFilesSDcard = new File(Environment.getExternalStorageDirectory()
.toString());
System.out.println("listFilesSDCard->"+listFilesSDcard);
getFolderList(listFilesSDcard, dirs);
System.out.println("ArrayList dirs Contains->"+dirs);
sgv = (GridView) dialog.findViewById(R.id.gridView);
sgv.setAdapter(new AppsAdapter1(dirs,pos1));
dialog.show();
}
/* Apps adapter for dialog gridview */
public class AppsAdapter1 extends BaseAdapter
{
ArrayList<File> dirsTemp1 = new ArrayList<File>();
//int pos5;
/*Arraylist dirs contains the sdcard image files*/
public AppsAdapter1(ArrayList<File>dirs,int pos10)
{
Log.d("In appsadapter2","Hiii");
dirsTemp1 = dirs;
pos2 = pos10;
}
//---returns the number of images---
public final int getCount()
{
return dirsTemp1.size();
}
//---returns the ID of an item---
public final Object getItem(int position)
{
return dirsTemp1.get(position);
}
public final long getItemId(int position)
{
return position;
}
public View getView(int position, View convertView, ViewGroup parent)
{
// TODO Auto-generated method stub
//int i=1;
View v = null;
Bitmap mOriginalBitmap = null;
//View view;
//Bitmap map1;
final File f = (File) getItem(position);
if (convertView == null)
{
LayoutInflater li = getLayoutInflater();
v = li.inflate(R.layout.gridicon, null);
ImageView iv = (ImageView) v.findViewById(R.id.imageView);
TextView tv = (TextView) v.findViewById(R.id.texttag);
tv.setTextColor(Color.BLACK);
String fName = f.getName();
if (f.isFile()) {
if (fName.endsWith(".png") || fName.endsWith(".jpeg")
|| fName.endsWith(".jpg")
|| fName.endsWith(".bmp"))
{
tv.setText(fName);
mOriginalBitmap =BitmapFactory.decodeFile(f.getAbsolutePath());
}
if (mOriginalBitmap != null)
{
mOriginalBitmap = Bitmap.createScaledBitmap(mOriginalBitmap, 75, 75, true);
iv.setImageBitmap(mOriginalBitmap);
}
}
}
else
{
v = convertView;
}
v.setOnLongClickListener(new OnLongClickListener()
{
public boolean onLongClick(View v)
{
// TODO Auto-generated method stub
// ***** I stuck here ****/
if (dialog != null)
dialog.dismiss();
String path = f.getAbsolutePath();
Toast.makeText(getBaseContext(),"long clicked",Toast.LENGTH_LONG).show();
Bitmap pass = BitmapFactory.decodeFile(path);
return false;
}
});
return v;
}
}
I just read images from sd card and shows it on a grid view in dialog. How did i replace the image on main grid view with the long clicked image on dialog grid view ? I got stuck with the onlong click listener of the dialog grid view .. Plz help me. thanks in advance..
I have a ListView and I want to display the selected list content in a popup when I click on it in the view. How can I do this?
Here's my code:
public class EventbyDate extends ListActivity {
Context cont;
private Runnable DateEventListThread;
public String DateEventListThreadResponse;
private ProgressDialog m_ProgDialog = null;
public DateEventListAdapter DateEventList_adapter;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.eventsbydate);
GetDateEventList();
this.DateEventList_adapter = new DateEventListAdapter(this,R.layout.eventsbydate_list,
RoamMeo_Config.DateEventList);
setListAdapter(this.DateEventList_adapter);
}
#Override
public void onPause() {
super.onPause();
this.finish();
}
void GetDateEventList() {
m_ProgDialog = ProgressDialog.show(EventbyDate.this, " Please wait",
"Collecting Data..", true);
DateEventListThread = new Runnable() {
#Override
public void run() {
DateEventListThread = null;
try {
} catch (Exception e) {
e.printStackTrace();
}
runOnUiThread(returnResponse);
}
};
Thread thread = new Thread(null, DateEventListThread, "DateEventListThread");
thread.start();
}
#Override
protected void onListItemClick(ListView l, View v, int position, long id) {
super.onListItemClick(l, v, position, id);
LayoutInflater inflater = (LayoutInflater) EventbyDate.
this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
PopupWindow pw = new PopupWindow(inflater.inflate(R.layout.popup,null,
false),300,400,true);
pw.showAtLocation(findViewById(R.id.txt_start_date),
Gravity.CENTER, 0,0);
}
private Runnable returnResponse = new Runnable() {
#Override
public void run() {
try {
if (DateEventListThreadResponse != null&&
DateEventListThreadResponse.length() > 0) {
boolean check =
XMLParsing.EventDate_List_Response(DateEventListThreadResponse);
if(check) {
DateEventList_adapter.notifyDataSetChanged();
} else {
Toast msg =
Toast.makeText(EventbyDate.this,"No list... ",Toast.LENGTH_LONG);
msg.setGravity(Gravity.CENTER,
msg.getXOffset() / 2,msg.getYOffset() / 2);
msg.show();
}
}
if (m_ProgDialog != null)
m_ProgDialog.dismiss();
m_ProgDialog = null;
} catch (Exception e) {
if (m_ProgDialog != null)
m_ProgDialog.dismiss();
m_ProgDialog = null;
}
}
};
class DateEventListAdapter extends ArrayAdapter<SaveDateEventList> {
ArrayList<SaveDateEventList> items;
public DateEventListAdapter(Context context, int
textViewResourceId,
ArrayList<SaveDateEventList> items) {
super(context, textViewResourceId, items);
this.items = items;
}
#Override
public View getView(int position, View convertView, ViewGroup
parent) {
View v = convertView;
final SaveDateEventList d = items.get(position);
if (v == null) {
LayoutInflater vi = (LayoutInflater)
getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = vi.inflate(R.layout.eventsbydate_list, null);
}
if (!items.isEmpty()) {
if (d != null) {
TextView start_date = (TextView)
v.findViewById(R.id.txt_start_date);
start_date.setText(d.ev_start_date);
TextView start_time = (TextView)
v.findViewById(R.id.txt_start_time);
start_time.setText(d.ev_start_time);
TextView poptext = (TextView)
v.findViewById(R.id.poptext);
poptext.setText(d.ev_start_time);
}
}
return v;
}
}
}
You can do something like this, protected void onListItemClick(ListView l, View v, int position, long id) {YourObject o = l.getItemAtPosition(position);}. After that you have to set what ever you need to display in your pop-up screen via this obtained object.