gpt4 book ai didi

android - 更改搜索栏时不调用 onProgressChanged 方法?

转载 作者:行者123 更新时间:2023-11-30 01:02:31 26 4
gpt4 key购买 nike

这是我使用的代码:

import android.support.v4.app.Fragment; 
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.SeekBar;

/**
* Created by Arsalan on 8/29/2016.
*/
public class ToolbarFragmnet extends Fragment implements
SeekBar.OnSeekBarChangeListener {

@Nullable
private static int s=10;
private static EditText editText;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.toolbar_fragment, container, false);
editText = (EditText) view.findViewById(R.id.edittext1);
final SeekBar seekBar = (SeekBar) view.findViewById(R.id.seekBar1);
final Button button = (Button) view.findViewById(R.id.button1);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
buttonClicked(view);
}
});
return view;
}

ToolbarListner callBackActivity;
public interface ToolbarListner {
public void onButtonClick(int position, String text);
}
@Override
public void onAttach(Context context) {
super.onAttach(context);
try {
callBackActivity = (ToolbarListner) context;
} catch (ClassCastException c) {
throw new ClassCastException(context.toString() + "must be implement");
}
}

private void buttonClicked(View view) {

callBackActivity.onButtonClick(s,editText.getText().toString());

}

@Override
public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
s= i
}

@Override
public void onStartTrackingTouch(SeekBar seekBar) {

}

@Override
public void onStopTrackingTouch(SeekBar seekBar) {

}
}

最佳答案

除非您将listener 设置为seekbar

,否则它永远不会被调用

把他放在onCreateView()方法中

seekBar.setOnSeekBarChangeListener(this);

关于android - 更改搜索栏时不调用 onProgressChanged 方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39244694/

26 4 0