ArrayList size becomes 0 inside onClick - java

public void confirmDelete(final ArrayList<Rec> list,final String d){
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this);
alertDialogBuilder.setMessage("Are you sure, You wanted to delete "+list.size()+" item(s)?");
System.out.println("list size " + list.size());
alertDialogBuilder.setPositiveButton("yes",
new DialogInterface.OnClickListener() {
#Override
public void onClick(DialogInterface arg0, int arg1) {
VaravuSelavu userDB = new VaravuSelavu(getBaseContext());
System.out.println("list size "+ list.size()+ " "+d);
if (userDB.deleteIncome(list, d))
{
re=userDB.displayIncome(dateView.getText().toString());
if (re != null) {
incomeAdapter = new ListViewAdapter(re, getBaseContext());
incomeAdapter.notifyDataSetChanged();
}
}
I want to pass the list inside the deleteIncome method.. the first print statement shows the correct size of the list... but inside the onClick method,the list size becomes 0... How to access the ArrayList inside onClick?

Related

Add Correct answers to Alert Dialog

Please help. I want to display the correct answers in an alert dialog, if i type "rightAnswers" inside "builder.setMessage("Answer : " + rightAnswers);" an alert show "Answer: 1". Number 1 instead of the correct answer. please teach me what to put to be able to display the correct answer. thank you so much.
public class thisactivity extends AppCompatActivity {
Button choice1,choice2;
ImageView images;
List<Model> list;
int turn = 1;
int rightAnswers = 0;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_thisactivity);
images = (ImageView) findViewById(R.id.images);
choice1 = (Button) findViewById(R.id.choice1);
choice2 = (Button) findViewById(R.id.choice2);
list = new ArrayList<>();
for (int i = 0; i < new Signsdatabase().answers.length; i++) {
list.add(new Model(new Signsdatabase().answers[i], new
Signsdatabase().signs[i]));
}
newQuestion(turn);
choice1.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
String alertTitle;
if(choice1.getText().toString().equalsIgnoreCase(list.get(turn -
1).getName())) {
rightAnswers = rightAnswers + 1;
alertTitle = "Correct!";
if (turn < list.size()) {
turn++;
newQuestion(turn);
} else {
Toast.makeText(thisactivity.this, "You have completed the Quiz!", Toast.LENGTH_SHORT).show();
}
}
AlertDialog.Builder builder = new
AlertDialog.Builder(thisactivity.this)
builder.setTitle(alertTitle);
builder.setMessage("Answer : " + **CORRECT ANSWERS**); <---I WANT TO DISPLAY THE CORRECT ANSWER HERE BUT I DO NOT KNOW HOW------->
builder.setIcon(R.drawable.pic);
builder.setPositiveButton("OK", new
DialogInterface.OnClickListener() {
#Override
public void onClick(DialogInterface dialog, int i) {
}
});
}
});
choice2.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
if (choice2.getText().toString().equalsIgnoreCase(list.get(turn - 1).getName())) {
rightAnswers = rightAnswers + 1;
if (turn < list.size()) {
turn++;
newQuestion(turn);
} else {
Toast.makeText(thisactivity.this, "You have completed the Quiz!", Toast.LENGTH_SHORT).show();
getResults();
}
} else {
}
AlertDialog.Builder builder = new
AlertDialog.Builder(Roadsigns.this)
builder.setTitle(alertTitle);
builder.setMessage("Answer : " + **CORRECT ANSWERS**); <---I WANT TO DISPLAY THE CORRECT ANSWER HERE BUT I DO NOT KNOW HOW------->
builder.setIcon(R.drawable.pic);
builder.setPositiveButton("OK", new
DialogInterface.OnClickListener() {
#Override
public void onClick(DialogInterface dialog, int i) {
}
});
builder.setCancelable(false);
builder.show();
}
});
}
............
And this is my Signsdatabase
public class Signsdatabase {
Integer[] signs ={
R.drawable.q1,
R.drawable.q2,
R.drawable.q3,
};
String[] answers = {
"Ans1",
"Ans2",
"Ans3",
};
}
Make this change in alter dialog.
make Signsdatabase object or make static in answer array.
builder.setMessage("Answer : " + Signsdatabase.answers[rightAnswers]);
You display the index of the right answer, you need to get the item from the list at the corresponding position:
builder.setMessage("Answer : " + signsdatabase.answers[rightAnswers]);
builder.setMessage("Answer : " + list[rightAnswers]);// it also check.
And you also need to initialize signsdatabase before
signsdatabase = new Signsdatabase();
Suppose you have the correct index of the answer You can do one of the following :
One
Create an object of SignsDatabase :
signsDb = new Signsdatabase();
With index i of correct answer :
builder.setMessage("Answer : "+ signDb.answers[i];
Two
If you do not want to create an instance of SignDatabase, you can declare the answers as static variable so :
public class SignDatabase{
... //some code here
public static String[] answers = ["Abc","xyz"];
}
Then access it directly by calling :
builder.setMessage(SignDatabase.answers[i]);

adding functionality to back key in android to go to previous folder location in a file manager

I know this has been discussed so many times but really I am not able to figure it out. I am so sorry for asking it again. I am making android file manager. I am showing the files and folders in a listview. I want to add functionality to "back" key. Currently pressing back key at any time results in exit from the app. I want it to go to the previous folder if any or otherwise exit the app. I was trying onBackPressed() method but couldn't figure out what should be written there. Please help me.
Here is my MainActivity.java file :
public class MainActivity extends ListActivity {
private ArrayList<String> item = null;
private ArrayList<String> path = null;
private String root="/";
private TextView myPath;
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); /**super keyword in java is a reference variable that
is used to refer immediate parent class object. */
setContentView(R.layout.activity_main);
myPath = (TextView)findViewById(R.id.path); /* storing the current path*/
getDir(root);
}
private void getDir(String dirPath)
{
myPath.setText("Location: " + dirPath);
item = new ArrayList<String>();
path = new ArrayList<String>();
File f = new File(dirPath);
File[] files = f.listFiles(); /** files is an array of all the files in a directory. */
if(!dirPath.equals(root))
{
item.add(root);
path.add(root);
item.add("../");
path.add(f.getParent());
}
for(int i=0; i < files.length; i++)
{
File file = files[i];
path.add(file.getPath());
if(file.isDirectory())
item.add(file.getName() + "/");
else
item.add(file.getName());
}
ArrayAdapter<String> fileList = new ArrayAdapter<String>(this, R.layout.row, item);
setListAdapter(fileList);
}
protected void onListItemClick(ListView l, View v, int position, long id) {
File file = new File(path.get(position));
if (file.isDirectory())
{
if(file.canRead())
getDir(path.get(position));
else
{
new AlertDialog.Builder(this)
.setIcon(R.drawable.icon)
.setTitle("[" + file.getName() + "] folder can't be read!")
.setPositiveButton("OK",
new DialogInterface.OnClickListener() {
#Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
}
}).show();
}
}
else
{
new AlertDialog.Builder(this)
.setIcon(R.drawable.icon)
.setTitle("[" + file.getName() + "]")
.setPositiveButton("OK",
new DialogInterface.OnClickListener() {
#Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
}
}).show();
}
}
you can try this:
#Override
protected void onBackPressed(){
//super.onBackPressed(); //remove it if you want control
String previousDir = "build your previous dir here";
if (previousDir != null){ //if deferent root path
Intent activityDir = new Intent(this, MainActivity.class);
activityDir.putExtra("DIR_PATH", previousDir);
startActivity(activityDir);
}//end if
finish(); //close this screen to show new screen above with new path
}
Note: you have to edit onCreate(....) as bellow code:
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); /**super keyword in java is a reference variable that
is used to refer immediate parent class object. */
setContentView(R.layout.activity_main);
myPath = (TextView)findViewById(R.id.path); /* storing the current path*/
if(getIntent() != null){
root = getIntent().getStringExtra("DIR_PATH", root); //if is null then get root
}
getDir(root);
}

ArrayIndexOutOfBoundsException / passing arraylist from alertdialog to activity

I have an alertdialog with multiple choices, I store the user's choices on an ArrayList of strings, and I want to pass the stored arraylist to the host activity (I will use the array's elements to query my database)..
When i run my app, i get an ArrayIndexOutOfBoundsException (may be the index is -1..), I'm not sure if it's the loop, or if i did not pass the arraylist correctly from the alertdialog...
can you guys take a look ? here is my function :
public void onOkay(ArrayList<String> selected) {
StringBuilder stringBuilder = new StringBuilder();
if (selected.size() != 0) {
for (int i = 0; i < selected.size(); i++) {
String categories = selected_items_array[selected.indexOf(i)];
stringBuilder = stringBuilder.append(" " + categories);
}
Toast.makeText(this, "You have selected: "
+ stringBuilder.toString(), Toast.LENGTH_SHORT).show();
}
}
logcat :
java.lang.ArrayIndexOutOfBoundsException: length=6; index=-1
at com.hichamridouane.smartshop.MainActivity.onOkay(MainActivity.java:164)
at com.hichamridouane.smartshop.TimelineSettings$2.onClick(TimelineSettings.java:71)
here is my dialogfragment class.
and here is my host activity.(as I said, i'm not sure if i'm passing correctly the arraylist to the host activity)
thanks !
It looks really strange to me, especially in
String categories = selected_items_array[selected.indexOf(i)];
From JavaDocs about indexOf
Returns the index of the first occurrence of the specified element
in this list, or -1 if this list does not contain the element.
More formally, returns the lowest index <tt>i</tt> such that
<tt>(o==null ? get(i)==null : o.equals(get(i)))</tt>,
or -1 if there is no such index.
So, you try to find element in your selected_items_array (not correct name in Java)
in first iteration i == 0, selected_items_array have no such element => indexOf return -1. Array can't have element with index = -1, it starts from 0. So you have your ArrayIndexOutOfBoundsException
Problem solved. Had to use Arraylists of integers in my activity and my dialogfragment.
here is what i did in my DialogFragment class:
public class TimelineSettings extends DialogFragment {
ArrayList<Integer> selected_categories = new ArrayList<Integer>();
boolean[] itemsChecked = {false, false, false, false, false, false};
// this interface to communicate with the host activity.
public interface dialoglistener {
public void onOkay(ArrayList<Integer> selected);
public void onCancel();
}
dialoglistener mlistener;
//this function is to instantiate the dialoglistener
#Override
public void onAttach(Activity activity) {
super.onAttach(activity);
try {
mlistener = (dialoglistener) activity;
} catch (ClassCastException e) {
throw new ClassCastException(activity.toString()
+ " must implement dialogListener");
}
}
My multichoice dialog :
#Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
for(int i=0;i<itemsChecked.length;i++){
if(selected_categories.contains((String)String.valueOf(i)))
itemsChecked[i]=true;
}
// Set the dialog title
builder.setTitle("Choisissez vos paramètres")
.setMultiChoiceItems(R.array.categories, itemsChecked,
new DialogInterface.OnMultiChoiceClickListener() {
#Override
public void onClick(DialogInterface dialog, int indexselected,
boolean isChecked) {
if (isChecked) {
// If the user checked the item, add it to the selected items
if(!selected_categories.contains(indexselected)){
selected_categories.add(indexselected);
itemsChecked[indexselected]=true;
}
} else if (selected_categories.contains(indexselected)) {
// Else, if the item is already in the array, remove it
selected_categories.remove(indexselected);
itemsChecked[indexselected]=false;
}
}
})
// Set the action buttons
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
#Override
public void onClick(DialogInterface dialog, int id) {
mlistener.onOkay(selected_categories);
}
})
.setNegativeButton("Annuler", new DialogInterface.OnClickListener() {
#Override
public void onClick(DialogInterface dialog, int id) {
mlistener.onCancel();
}
});
return builder.create();
}
On my host activity, I implemented the fragment's interface :
#Override
public void onCreate(Bundle savedInstanceState) {
/* some fancy stuff */
Resources res = getResources();
selectedArray = res.getStringArray(R.array.categories);
}
Getting the selected items (and show them on a toast, just for testing) :
#Override
public void onOkay(ArrayList<Integer> selected) {
StringBuilder stringBuilder = new StringBuilder();
if (selected.size() != 0) {
for (int i = 0; i < selected.size(); i++) {
String categories = selectedArray[selected.get(i)];
stringBuilder = stringBuilder.append(" " + categories);
}
Toast.makeText(this, "You have selected: "
+ stringBuilder.toString(), Toast.LENGTH_SHORT).show();
}
}

How to sort files using datetimestamp

I am capturing images, then storing into SD Card and showing in a List, but here i need a small change, still i am getting old on top and latest at bottom, so now i want to show latest picture on the top on the basis of datetimestamp using as a part of file name.
UploadActivity.java code:-
String fileName;
static List <String> ImageList;
/*** Get Images from SDCard ***/
ImageList = getSD();
// ListView and imageAdapter
lstView = (ListView) findViewById(R.id.listView1);
lstView.setAdapter(new ImageAdapter(this));
}
public static List <String> getSD()
{
List <String> it = new ArrayList <String>();
String string = "/mnt/sdcard/Pictures/SamCam/";
f = new File (string+ CameraLauncherActivity.folder+ "/");
files = f.listFiles ();
for (int i = 0; i < files.length; i++)
{
file = files[i];
Log.d("Count",file.getPath());
it.add (file.getPath());
}
return it;
}
public class ImageAdapter extends BaseAdapter
{
private Context context;
public ImageAdapter(Context c)
{
// TODO Auto-generated method stub
context = c;
}
Note: I am using date/timestamp while storing my images into SD Card.
so finally it looks like this:
AU_20140328163947_1_4_X-1-4-006.jpg
and still files listing in below format, like below:
AU_20140328163947_1_4_X-1-4-006.jpg
AU_20140328163948_1_4_X-1-4-007.jpg
AU_20140328163949_1_4_X-1-4-008.jpg
but i want to list files in below format:-
AU_20140328163949_1_4_X-1-4-008.jpg
AU_20140328163948_1_4_X-1-4-007.jpg
AU_20140328163947_1_4_X-1-4-006.jpg
Code to Delete Image in a List:--
// btnDelete
final ImageButton btnDelete = (ImageButton) convertView.findViewById(R.id.btnDelete);
btnDelete.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View arg0) {
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(context);
// set title
alertDialogBuilder.setTitle("Delete Image");
// Setting Icon to Dialog
alertDialogBuilder.setIcon(R.drawable.ic_launcher);
// set dialog message
alertDialogBuilder
.setMessage("Are you sure you want to delete this image?")
.setCancelable(false)
.setPositiveButton("Yes",new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,int id) {
// if this button is clicked, close
// current activity
// to get fileName
fileName = ImageList.get(position).toString().substring(strPath.lastIndexOf('/')+1, strPath.length());
// to get SD card path (Folders+fileName)
String fileToDelete = Environment.getExternalStorageDirectory().getPath() +"/Pictures/SamCam/" + CameraLauncherActivity.folder+ "/" + fileName;
Log.d("FileToDelete", fileToDelete);
File myFile = new File(fileToDelete);
// if image exists
if(myFile.exists())
// delete image
myFile.delete();
// get position and delete
ImageList.remove(position);
// to refresh the view
((BaseAdapter) lstView.getAdapter()).notifyDataSetChanged();
dialog.cancel();
}
})
.setNegativeButton("Cancel",new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,int id) {
// if this button is clicked, just close
// the dialog box and do nothing
dialog.cancel();
}
});
// create alert dialog
AlertDialog alertDialog = alertDialogBuilder.create();
// show it
alertDialog.show();
// TODO Auto-generated method stub
}
});
return convertView;
}
}
If you getting data in reverse order than you can use reverse loop.
Try below loop
for (int i = files.length-1; i >= 0; i--)
{
file = files[i];
Log.d("Count",file.getPath());
it.add (file.getPath());
}
instead of
for (int i = 0; i < files.length; i++)
{
file = files[i];
Log.d("Count",file.getPath());
it.add (file.getPath());
}
or sort data with particular field
Sort array data before using in for loop and use same loop..
Arrays.sort(files, new Comparator<Object>()
{
public int compare(Object o1, Object o2) {
if (((File)o1).lastModified() > ((File)o2).lastModified()) {
return -1;
} else if (((File)o1).lastModified() < ((File)o2).lastModified()) {
return +1;
} else {
return 0;
}
}
});
for (int i = 0; i < files.length; i++)
{
file = files[i];
Log.d("Count",file.getPath());
it.add (file.getPath());
}
Use MediaStore ContentProvider for this job
Save the image using MediaStore using this method
And you can query the image using this method
Set the order by as MediaStore.Images.Media.DATE_TAKEN
You can use the Collections.sort method in your list adapter to sort the values according to the image file name like:
Collections.sort(ImageList, new Comparator<String>() {
int compare(String obj1, String obj2) {
return obj1.compareTo(obj2);
}
});
compareTo method and also compareToIgnoreCase method, use wichever you think is appropriate, and also, you can experiment with obj1 and obj2, that is, you could swap the condition to:
return obj2.compareTo(obj1);
That way your list will be sorted. Hope that helps!
EDIT:
Since you know that the format is _ and then -.jpg, what you can do is in the comparator split the value from - like:
Collections.sort(ImageList, new Comparator<String>() {
int compare(String obj1, String obj2) {
String[] obj1Arr = obj1.split(-);
String[] obj2Arr = obj2.split(-);
obj1Arr = obj1Arr[1].split("."); // to just get the counter value
obj2Arr = obj2Arr[1].split(".");
return obj1Arr[0].compareTo(obj2Arr[0]);
}
});

How to clear all items in a ListView while using List Adapter onTextChange?

I have been trying to find answers, but it has been hard to find a solution that works.
I tried setting the adapter to null, clearing the actual list but neither seems to work.
I am using a ListView with a ListAdapter and am trying to make it clear on a change of search Text when text is changed.
list.clear(); works but it does not occur on text change.
Here is my code:
private EditText search_input;
private Button search_button;
// progress bar for search results
private ProgressDialog search_loading;
private ListView wordSearchList;
private ListAdapter adapter;
// no result layout
private LinearLayout no_res;
// create list for adapter
ArrayList<HashMap<String, String>> list;
// database helper
private DatabaseHelper db;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.dictionary_search);
search_input = (EditText) findViewById(R.id.search_dictionary);
search_button = (Button) findViewById(R.id.search_button);
search_button.setOnClickListener(this);
// linear layout for no results
no_res = (LinearLayout) findViewById(R.id.search_result_ll);
// create hashmap list
list = new ArrayList<HashMap<String, String>>();
// remove views if they exist
search_input.addTextChangedListener(new TextWatcher() {
#Override
public void onTextChanged(CharSequence s, int start, int before,
int count) {
// REMOVE LIST VIEW AND ADAPTER
// list.clear();
if (no_res.getChildCount() > 0) {
no_res.removeAllViews();
}
}
#Override
public void beforeTextChanged(CharSequence s, int start, int count,
int after) {
}
#Override
public void afterTextChanged(Editable s) {
}
});
}
#Override
public void onClick(View v) {
if (v == search_button) {
// clear list for fresh start
list.clear();
no_res.removeAllViews();
// validate input and that something was entered
if (search_input.getText().toString().length() < 1) {
// missing required info (null was this but lets see)
Toast.makeText(getApplicationContext(),
"Please search for something!", Toast.LENGTH_LONG)
.show();
} else {
String search_data;
search_data = search_input.getText().toString();
// remove any current views on search again
// REMOVE THE LIST VIEW
// execute the query search
List<DatabaseWordsFTS> search_results = db
.getSingleWordSearch(search_data);
// if no search results returned
if (search_results.size() <= 0) {
TextView no_results_tv = new TextView(this);
no_results_tv.setText("No results found.");
no_res.addView(no_results_tv);
}
// setup listview
wordSearchList = (ListView) findViewById(R.id.wordSearchList);
for (DatabaseWordsFTS word_found : search_results) {
// have to create hashmap in loop
HashMap<String, String> map = new HashMap<String, String>();
// convert d id to long
Integer dictionary_id_convert = (int) (long) word_found._dictionaryId;
// extract dictionary from d-id - since it is not a list and
// just a variable
DatabaseDictionary dictionary_found = db
.getDictionary(dictionary_id_convert);
// extract languages to send below
Integer dln_1 = (int) dictionary_found._language1Id;
Integer dln_2 = (int) dictionary_found._language2Id;
Integer dln_3 = (int) dictionary_found._language3Id;
Integer dln_4 = (int) dictionary_found._language4Id;
// get languages for the words based on ids passed in
List<DatabaseLanguages> LanguagesForD = db
.getAllLanguagesWithId(dln_1, dln_2, dln_3, dln_4);
// add name to hashmap and rest of the data as strings
map.put("w_1", word_found.get_word1_fts());
map.put("l_1", LanguagesForD.get(0)._language_name);
map.put("d_id", String.valueOf(dictionary_id_convert));
map.put("w_id", String.valueOf(word_found.get_id()));
if (word_found.get_word2_fts() != null) {
map.put("w_2", word_found.get_word2_fts());
map.put("l_2", LanguagesForD.get(1)._language_name);
}
if (word_found.get_word3_fts() != null) {
map.put("w_3", word_found.get_word3_fts());
map.put("l_3", LanguagesForD.get(2)._language_name);
}
if (word_found.get_word4_fts() != null) {
map.put("w_4", word_found.get_word4_fts());
map.put("l_4", LanguagesForD.get(3)._language_name);
}
list.add(map);
// used to dismiss progress bar for searching
search_loading.dismiss();
}
String[] from = { "w_1", "w_2", "w_3", "w_4" }; // , "word3",
// "word4"
int[] to = { R.id.textName, R.id.textLanguage };
adapter = new SimpleAdapter(this, list,
R.layout.dictionary_row, from, to);
wordSearchList.setAdapter(adapter);
wordSearchList
.setOnItemClickListener(new AdapterView.OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> parent,
View view, int position, long id) {
// ListView Clicked item index
int itemPosition = position;
// ListView Clicked item value
HashMap itemValue = (HashMap) wordSearchList
.getItemAtPosition(position);
String w_id = (String) itemValue.get("w_id");
String d_id = (String) itemValue.get("d_id");
String l_1 = (String) itemValue.get("l_1");
String l_2 = (String) itemValue.get("l_2");
String l_3 = (String) itemValue.get("l_3");
String l_4 = (String) itemValue.get("l_4");
String w_1 = (String) itemValue.get("w_1");
String w_2 = (String) itemValue.get("w_2");
String w_3 = (String) itemValue.get("w_3");
String w_4 = (String) itemValue.get("w_4");
// Show Alert
Toast.makeText(
getApplicationContext(),
"Position :" + itemPosition
+ " ListItem : " + w_id,
Toast.LENGTH_LONG).show();
// creating bundle
Bundle d_data = new Bundle();
// add to bundle
d_data.putString("w_id", w_id);
d_data.putString("wd_id", d_id);
d_data.putString("w_1", w_1);
d_data.putString("l_1", l_1);
// get tags only if it exists
if (w_2 != null) {
d_data.putString("w_2", w_2);
d_data.putString("l_2", l_2);
}
if (w_3 != null) {
d_data.putString("w_3", w_3);
d_data.putString("l_3", l_3);
}
if (w_4 != null) {
d_data.putString("w_4", w_4);
d_data.putString("l_4", l_4);
}
// start new intent based on the tag -
Intent single_word_view = new Intent(
DictionaryWordSearch.this,
DictionarySingleWordView.class);
// call extras
single_word_view.putExtras(d_data);
// new_dictionary_view.putExtra("d_id",
// WhatAmISupposeToPassInHere);
startActivity(single_word_view);
}
});
}
EDIT: (Below worked for me)
Changed ListAdapter to SimpleAdapter
if(adapter != null){list.clear(); adapter.notifyDataSetChanged();}
Added the above code in onTextChange
Look if you want the TextView with no result you can implement this code
listView.setEmptyView(emptyView)
and pass your TextView to this method ,
for clearing the ListView you can clear your collection and call notifyChangeDataSet or set adapter with null try both and feed me back

Categories

Resources