Hide/show AChartEngine series using checkboxes - android

Basically I have a chart with four different series, that by default shows all four of them at the same time. I want to allow the user to hide and/or show them again as he pleases by marking checkboxes.
I found a similar question here and followed both the advices given, but it didn't work. Here is what one of my checkboxes looks like now:
checkBox1.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
if(((CheckBox)v).isChecked()){
multiRenderer.addSeriesRenderer(distanceRenderer);
// distanceRenderer.setColor(Color.parseColor("#990000")); //(making transparent method)
}
else{
//distanceRenderer.setColor(Color.TRANSPARENT); //(making transparent method)
multiRenderer.removeSeriesRenderer(distanceRenderer);
}
}
});
The idea is to when I uncheck the checkbox, I will hide that one renderer, when I check it again, it will be added again.
In the suggestions of the thread I linked to, they said to remove all renderers and then reenter the ones that aren't supposed to be hidden. I also tried this, but to no avail. The third option was simply to change the color to transparent whenever I wanted it to disappear, this also didn't work.
I debugged it, and it is getting in the conditions correctly, but nothing happens. Is there something I need to call that I've missed?
Thanks!
Edit: I don't know if this somehow helps, but I also tried to call the XYMultipleSeriesDataset's function repaint(). This caused an IllegalStateException, soooo.... Still no good...

Try this for hide purpose :
r.setColor(Color.TRANSPARENT);
mChartView.repaint();
where r is XYSeriesRenderer .

Related

Android talkback not reading the content of the dialog box

I have tried to show the dialog box while the user giving the wrong username or password, using the below code.
private void showAlert(String title, String msg) {
customDialog = new Dialog(LoginActivity.this,
android.R.style.Theme_Dialog);
customDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
customDialog.setContentView(R.layout.custom_alert_dialog);
tvTitle = (TextView) customDialog
.findViewById(R.id.dialog_title);
tvMsg = (TextView) customDialog
.findViewById(R.id.dialog_message);
btnNeutral = (Button) customDialog
.findViewById(R.id.closeAlert);
tvMsg.setText(msg);
tvTitle.setText(title);
tvMsg.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_FOCUSED);
tvMsg.setFocusable(true);
btnNeutral.setText("Close");
btnNeutral.setVisibility(View.VISIBLE);
btnNeutral.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
customDialog.dismiss();
}
});
customDialog.show();
tvMsg.requestFocus();
}
The code working fine but my concern is, when i am trying to use the android talkback. It reads only the title of the dialog box. The talkback needs to read the content(message) of the dialog box instead of title. Can anyone help me to do this?
First, announcing just the title of a new dialog is very standard. Doing otherwise would probably be counter productive in terms of accessibility. This sounds to me like an accessibility requirement from someone motivated to do good, that doesn't really understand the needs of users with disabilities. Shoving focus around arbitrarily is usually bad. Let the operating system do what it wants with focus, it is what Assistive Technology (TalkBack) users will be accustomed to.
This said there are two overarching issues with your code. First, when you say focus, you mean accessibility focus.
tvMsg.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_FOCUSED);
tvMsg.setFocusable(true);
tvMsg.requestFocus();
All of these lines are referring to keyboard, or input focus, none of which are particularly meaningful for a TextView. These are only meaningful for active elements like Buttons and EditText boxes. Will this work if you do it correctly, yes. But, it comes with awkward side effects, like a TextView being added to Tab ordering, which is awkward for Keyboard only users, because TextViews don't have focus highlights, so Focus navigation disappears. What you really want is the following event type:
AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED
Now, for the second point. You're doing all of this before your view actually renders. Replace this line:
tvMsg.requestFocus();
With this line:
tvMsg.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED);
Delete the other lines mentioned above, and you should be golden. Though, again, my ultimate recommendation would just be dropping all of this, and removing those three lines outright, and forgetting about this. Let the operating system do its thing!

xamarin mutli selection listview

It's been a while that i'm trying to get an anwser to my problem, but i didn't find it... So i'm searching for your help.
I work on xamarin to make an android application but i dont use Xamarin.Forms (i would have used it, if i knew it when i begin the project
I'll directly to the point, if you have some question, just ask me.
So i got a Listview where i can select 2 or more items :
private void _listViewIntervention_ItemClick(object sender, AdapterView.ItemClickEventArgs e)
{
_intervention[e.Position].IsSelected = !_intervention[e.Position].IsSelected;
if (_intervention[e.Position].IsSelected)
e.View.SetBackgroundColor(Android.Graphics.Color.Rgb(255, 127, 127));
else
e.View.SetBackgroundColor(Android.Graphics.Color.Rgb(230, 230, 230));
_numberInterventionSelected.Text = _intervention.FindAll(elem => elem.IsSelected == true).Count().ToString();
}
That thing work but if i have a listview with 20 items i.e and i select 3 items, if i scroll the listview, everything will be disturb and my 3 highlighted rows won't be anymore and the highlight will be on another row that i've never select.
I think that not that evident and it might be blur.
IMO i'm not changing the good thing when i do the "e.View.SetBackgroundColor" but i've try lot of thing that never worked.
I might not going the best way to do what i want to do btw.
The result i want is when i scroll the listview, nothing change so i can select the first and the last item of the listview i.e.
I search again in my side but i count a little on you know...
Thanks for reading and have a good day !
I have already getting same problem after lot of search and find the solution
In Xamarin custom adapter remove ViewHolder System it's working fine after removing Holder system

Android - AutoCompleteTextView not showing after setText is called

I'm having a weird issue with AutoCompleteTextView.
I have a AutoCompleteTextView that shows suggestions of cities when typing in it.
The list of cities is retrieved from a remote server via JSON. When I use the soft keyboard or the Mic Button on the soft keyboard, the suggestions work fine. AutoCompleteTextView does show the suggested cities.
But, I have a problem when I try to set the text using myAutoCompleteTextView.setText("Chi") , the auto complete does not show..
I have also tried myAutoCompleteTextView.append("Chi") but still no luck..
The adapter is there, its just that the suggestions don't show.
Any tips?
Thanks.
Yes you are right there is a bug in AutocompleteTextview to show default suggestion using setText(""); method.
But you can achieve this by adding some more lines of code as below.
autoText.postDelayed(new Runnable() {
#Override
public void run() {
autoText.showDropDown();
}
},500);
autoText.setText("chi");
autoText.setSelection(autoText.getText().length());
It is due to filtering,
No Need to any extra code for manage it, I found it in very easy and working way.
Google Dev. Reference link
autoText.setText("Default Value here",false)
autoText.setSelection(autoText.text.count()) // kotlin
as per documentation second parameter you can pass for filtering.
boolean: If false, no filtering will be performed as a result of this call.
Biraj Zalavadia's answer work, but you must write to "settext" in Runnable.
Like this:
mACTextViewEmail.postDelayed(new Runnable() {
#Override
public void run() {
mACTextViewEmail.showDropDown();
mACTextViewEmail.setText("My text is here");
mACTextViewEmail.setSelection(mACTextViewEmail.getText().length());
}
},500);
I searched for it and just found this solution that worked so well
Look at this issue
fun AutoCompleteTextView.showDropdown(adapter: ArrayAdapter<String>?) {
if(!TextUtils.isEmpty(this.text.toString())){
adapter?.filter?.filter(null)
}
}
In kotlin language, you can use this extension function.

Android table-layout not rendering real-time

I'm a newbie to android facing a UI update problem.
I have some TextViews and EditText widgets in rows of a table-layout.
When the user clicks on an item on a list, I want to populate the details of that item into this table.
I believe my code for updating the edittext widgets is working find and I can see that it has been updated.
However,I observe the table-row becomes blank on an update and when I click on the edittext, only then can I see the updated text (I guess I can see updated text only on onFocus() or something).
Could someone please tell me why does it behave this way?
Thanks
When you update the view use another thread and call invalidate();
yourEditText.post(new Runnable() {
#Override
public void run() {
yourEditText.setText("your text");
yourEditText.invalidate();
}
});

Displaying an array of objects, one at a time through a single dialog... instead of several dialogs

In my application I have a list of questions stored in an ArrayList, and I want to display a dialog that shows one question, and then continues to the next one after the question is answered. The way that I'm currently doing it (iterating through a loop) hasn't been working because it just layers all of the dialogs on top of one another all at once which causes a host of other issues. What I'm looking for is a way to still iterate through the questions, but just change the layout of the dialog each time until it has finished each question in the list. Can anyone give me a good pointer for how to get this going?
You can make a function that takes title and message as parameters and shows a dialog.
showDialog(String title, String message){ // Show dialog code here}
Within that dialog's answer button's listener call another function (showQuestion(currentQuestion)) that iterates the arrayList till it is over
int currentQuestion=0;
ArrayList<QuestionObject> questionList;
showQuestion(int i){
if(i<questionList.size()){
showDialog(questionList.get(i).getTitle,questionList.get(i).getMessage);
currentQuestion++;
}else{
//quiz is over
}
}
I assume you mean that you just want to change 1 single layout(created within XML i.e main.xml). In order to do this, make sure that the class your working on is pointing to that layout. From there (assuming your using an Event listener for when the user submits an answer) you can change do as you want by the following:
TextView txt = (TextView) findViewById(R.id.textView); // references the txt XML element
and in your Event listener, if the answer is correct then change(Have i be a global variable thats initially set to 0).
if(i<arrayList.size()){
txt.setText(arrayList.get(++i));
}else{
txt.setText("You Finished");
}
From there, in the else statement, you can change arrayLists and reset i to 0;
If you are trying to use the positive, neutral, and negative buttons; then you may have problems with multiple dialogs. Try defining a customized layout with your own TextViews, ListViews, and Buttons. You can implement listeners and everything else like a regular layout. Then just pass your customized layout to the dialog through AlertDialog.Builder.setView().
PS If you include code examples of what you are currently doing we can provided answers that are less vague.

Categories

Resources