Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
When try tu add method setOnItemClikListener show me this error: setOnItemClikListener (ItemClikListener) in AdapterView cannot be applied to ().
My code is:
List<String> weekForecast = new ArrayList<String>(Arrays.asList(forecastArray));
mForecastAdapter = new ArrayAdapter<String>(getActivity(),R.layout.list_item_forecast,R.id.list_item_forecast_textview,weekForecast);
ListView listViewForecast = (ListView) rootView.findViewById(R.id.listview_forecast);
listViewForecast.setAdapter(mForecastAdapter);
listViewForecast.setOnItemClickListener();
Try the following :
List<String> weekForecast = new ArrayList<String>(Arrays.asList(forecastArray));
mForecastAdapter = new ArrayAdapter<String>
(getActivity(),android.R.layout.simple_list_item1,weekForecast);
ListView listViewForecast = (ListView) rootView.findViewById(R.id.listview_forecast);
listViewForecast.setAdapter(mForecastAdapter);
listViewForecast.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
//Do your thing here
}
});
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
enter image description here
i have already created gridview.i want to remove the images by a single click.
thank u.
Pretty simple,
Assuming that you are using recyclerview
class ViewHolder extends RecyclerView.ViewHolder {
View vCross;
ViewHolder(View itemView) {
vCross = itemView.findViewById(R.id.your_view_id) // Giving reference
vCross .setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
// Assuming dataset is your adapter dataset
dataSet.remove(getAdapterPosition());
notifyItemRemoved(getAdapterPosition());
}
});
}
}
Summary, In your ViewHolder, when user clicks on remove button - remove item from your adapter dataSet and notify adapter that, item has been removed at specific position.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I am Developing a small Dictionary App Using Sqlite Database Where There are Two Columns..Word and Word Definition.. Now how can I populate AutoCompleteTextView So that When an user start to Type any Word for Searching I can Show him/her All the Words from word Column based On his/her first typed Letter?
Have you checkout the docs, there's a good example on how to use AutoCompleteTextView there.
public class CountriesActivity extends Activity {
protected void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.countries);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_dropdown_item_1line, COUNTRIES);
AutoCompleteTextView textView = (AutoCompleteTextView)
findViewById(R.id.countries_list);
textView.setAdapter(adapter);
}
private static final String[] COUNTRIES = new String[] {
"Belgium", "France", "Italy", "Germany", "Spain"
};
}
Using the above example you would just need to retrieve your words into the array and pass it to the adapter.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
Ara>Button,Dizi>array.
when i clicked button list the botton of list view? is there any body help me?
Help,help
ps: i tried something but not worked
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);//
setContentView(R.layout.activity_main);
Ara = (Button)findViewById(R.id.btnAra);
multitv =(MultiAutoCompleteTextView) findViewById(R.id.multiAutoCompleteTextView1);
adapter =new ArrayAdapter<String>(this,android.R.layout.select_dialog_singlechoice, Neresi());
multitv.setAdapter(adapter);
multitv.setTokenizer(new MultiAutoCompleteTextView.CommaTokenizer());
Aranan = (String)multitv.getText().toString();
listView = (ListView) findViewById(R.id.list);
listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
Ara.setOnClickListener(this) ;
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
if(v.getId() == R.id.btnAra)
{
String []dizi =null;
dizi = Belirtiler("Baş");
adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_multiple_choice,dizi);
listView.setAdapter(adapter);
}
}
for refreshing list see the following link
How to refresh Android listview
Android Updating ListView
Android: how to refresh ListView contents
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I have requirement for filtering category type -> category -> products. For this I have to use nested spinner as we have in eclipse package explorer.
How can I achieve?
Look, I am not sure if you are looking for something like that. I have 2 spinner, when the user select a item from brandspinner, the modelspinner is setted with all the products of this brand.
private Spinner brandSpinner;
private Spinner modelSpinner;
brandSpinner = (Spinner)root.findViewById(R.id.brand_spinner);
modelSpinner = (Spinner)root.findViewById(R.id.model_spinner);
brandsAdapter = new ArrayAdapter<BrandItem>(mContext, android.R.layout.simple_spinner_dropdown_item, ArrayListWithBrands);
//I am not sure if it is needed:
brandsAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
brandSpinner.setAdapter(brandsAdapter);
brandSpinner.setOnItemSelectedListener(new OnItemSelectedListener() {
#Override
public void onItemSelected(AdapterView<?> a, View v, int pos, long id) {
//Harcoding Brands:
BrandItem brand = brandsArrHarcode.get(pos);
final ArrayList<String> modelsArr = brand.getModels();
modelsAdapter = new CustomArrayAdapter(mContext, android.R.layout.simple_spinner_dropdown_item, modelsArr);
modelsAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
modelSpinner.setAdapter(modelsAdapter);
modelSpinner.setSelection(modelsAdapter.getPosition(camera.getModel()));
}
#Override
public void onNothingSelected(AdapterView<?> a) {}
}
);
Hope to be helpful.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
I want to add value getting from text view of android to an existing array list.e.g. my current array list contain values Cricket,Football and by text view I want to add hockey in array list at last position ..then my array list become Cricket ,football,hockey. My array list of cricket and football is coming from previous activity.
But now it add only cricket and football but does not add hockey
How can I do it?
resultArrGame+=resultArrGame.add(txtGame.getText().toString());
This will definitely work for you...
ArrayList<String> list = new ArrayList<String>();
list.add(textview.getText().toString());
list.add("B");
list.add("C");
You're trying to assign the result of the add operation to resultArrGame, and add can either return true or false, depending on if the operation was successful or not. What you want is probably just:
resultArrGame.add(txt.Game.getText().toString());
you can use this add string to list on a button click
final String a[]={"hello","world"};
final ArrayAdapter<String> at=new ArrayAdapter<String>(getApplicationContext(), android.R.layout.simple_list_item_1,a);
final ListView sp=(ListView)findViewById(R.id.listView1);
sp.setAdapter(at);
final EditText et=(EditText)findViewById(R.id.editText1);
Button b=(Button)findViewById(R.id.button1);
b.setOnClickListener(new OnClickListener()
{
#Override
public void onClick(View v)
{
// TODO Auto-generated method stub
int k=sp.getCount();
String a1[]=new String[k+1];
for(int i=0;i<k;i++)
a1[i]=sp.getItemAtPosition(i).toString();
a1[k]=et.getText().toString();
ArrayAdapter<String> ats=new ArrayAdapter<String>(getApplicationContext(), android.R.layout.simple_list_item_1,a1);
sp.setAdapter(ats);
}
});
So on a button click it will get string from edittext and store in listitem.
you can change this to your needs.
item=sp.getItemAtPosition(i).toString();
list.add(item);
adapter.notifyDataSetChanged () ;
look up ArrayAdapter.notifyDataSetChanged()