Set seekbar indeterminate on true at button click - android

I have a SeekBar:
SeekBar seekBar = (SeekBar) findViewById(R.id.seekBar1);
I have for it a custom indeterminate drawable set in xml:
android:indeterminateDrawable="#drawable/progress_indeterminate_horizontal"
From code
seekBar.setIndeterminate(true);
works, but when I want to set indeterminate to true at on button click doesn't work - the seekbar become black.
Button startIndeterminateMode = (Button) findViewById(R.id.startIndeterminateMode);
startIndeterminateMode.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
seeekBar.setIndeterminate(true);
}
});

I am not sure if seekbar supports indeterminate mode, You should rather have seekbar and Progressbar in a single layout and make them visible and GONE alternatively depending upon onClick

Related

Layout as selector item in Android

I need to use text view as CheckBox background and set different color for each state. Some how I managed to get it with Java. But I don't think it is the
proper way. Is there any other method to achieve this?
Implement onClickListener to your textview, something like:
int ispressed = 0;
TextView txtview = (TextView) findViewbyId(R.id.textview1);
txtview.setOnClickListener(new new View.OnClickListener() {
#Override
public void onClick(View v) {
if(ispressed=0){
//CHANGE BACKGROUND COLOR
ispressed=1;
}else{
//RESTORE BACKGROUND COLOR
}
}
});

Android ProgressBar onclick

I have a progress bar that I want to click on and move the progress to the point clicked.
i have
pb = (ProgressBar) v.findViewById(R.id.progressBar);
pb.setOnClickListener(new ProgressBar.OnClickListener() {
public void onClick(View v) {
//
}
}
Basically I want it to behave like a SeekBar, but I need to use a progress bar because I am using a circular progress bar, and the code I have visually fits my needs.
cheers,
I went with a custom seekbar
https://github.com/JesusM/HoloCircleSeekBar/blob/master/lib/src/main/java/com/jesusm/holocircleseekbar/lib/HoloCircleSeekBar.java
This is a circular seekbar, as per my requirements

When button gets clicked, make it dissapear, randomely change bg color and load text from database?

I am busy creating an app. I succeeded in creating the button with a custom font and all. Now what I'd want is that when I click the button, it must disapear, the background color of the view must randomely change and text must be loaded from an database.
How does one go about this?
Matthew
Well, the disappearing can be make like this:
public class MyActivity extends Activity {
protected void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.content_layout_id);
final Button button = (Button) findViewById(R.id.button_id);
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// Perform action on click - Disappear in your case...
v.setVisibility(View.INVISIBLE); //can be View.GONE as well...
}
});
}
}
Then for the background I guess you can create an array with all the colors you want (or something that generates a random HEX code) and then do setBackground(X) where X is the HEX code that you just generated... You need to specify more about the database part though.

Android: seekbar in button

I have a Button in my android application, and I need to expand it on click and display a Seekbar inside it, like at the picture below. What is the best practice to do that?
Use below code to handle tap of button to set visiblility of seekbar invisible if visible or visible if invisible.
Button click = (Button) findViewById(R.id.but);
Seekbar seek = (Seekbar) findViewById(R.id.seek);
click.setOnClickListener(new OnClickListener()
{
public void onClick(View v) {
if (seek.getVisibility() == View.VISIBLE) {
seek.setVisibility(View.INVISIBLE);
} else {
seek.setVisibility(View.VISIBLE);
}
}
});

Android textView disappears when clicked

I have a TextView with the android:onClick attribute. When clicked, the TextView disappears. I don't want the TextView to disappear when clicked. Any ideas?
Edit:
<TextView android:id="#+id/textView1"android:text="Click Me!"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:onClick="processClick"
android:clickable="true"/>
http://i1179.photobucket.com/albums/x386/jenningsr2006/unclicked.png
http://i1179.photobucket.com/albums/x386/jenningsr2006/clicked.png
Edit
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.example);
TextView t = (TextView)findViewById(R.id.textView1111);
t.setOnClickListener(new OnClickListener()
{
#Override
public void onClick(View v)
{
// Do some job here
Toast.makeText(getApplicationContext(), "Clicked", Toast.LENGTH_SHORT).show();
}
});
Clicking it does the operation correctly, that's not the problem. When I "mousedown" on the TextView, it disappears, then reappears on "mouseup".
I thought I had the same problem but it turned out the textview was not dissapearing, rather the color was changing so that it was the same as the background color. Thus it appeared hidden but it really was there. You can set the clicked color of the text view by setting it's color state list resource
http://developer.android.com/guide/topics/resources/color-list-resource.html
Have you registered a method processClick? There is no need to do it this way. Remove the clickable property and also onClick property. More simple approach is to set onClick listener from the code, for example in onCreate method:
TextView text = (TextView) findViewById(textView1);
text.setOnClickListener(new OnClickListener()
{
#Override
public void onClick(View v)
{
// Do some job here
}
});
The view becomes clickable automatically when you set an on click listener. Good luck

Categories

Resources