我已经实现了一个 textwatcher,所以当我在写一些东西时,我希望我的进度条变得可见(当然还有如何让它在 onCreate 中不可见)
进度条:
ProgressBar pb = (ProgressBar) findViewById(R.id.progressbar);
pb.setProgress(0);
int k = (int)max;
pb.setMax(k);
int j = (int)(cost);
pb.setProgress(j);
Run Code Online (Sandbox Code Playgroud)
这个代码用于进度条,只取一个int值,我想更改代码以获取double值
我有5个搜索栏,希望用户能够操纵它们。搜索杆彼此依赖,因此如果将搜索杆设置为100%,则所有其他搜索杆都必须为0%。我已经能够实现这个使用中发现的代码这个帖子操纵seekbars但是当它出问题和搜索条跳动。例如,默认情况下,我将所有搜索栏设置为20%。为了将seekbar_1提高20%,您将另一个seekbar的值降低了(例如,seekbar_2降低了20%)。这释放了seekbar_1可以使用的20%。我的问题是搜索栏的实际触摸和移动,由于我在onProgressChanged方法中进行了各种计算,因此它会跳动。我在下面附加了我的代码。有没有更简单的方法来实现这一目标?任何帮助将非常感激。
public class MainActivity extends Activity implements OnSeekBarChangeListener{
public SeekBar sb1,sb2,sb3,sb4,sb5;
public TextView tv1,tv2,tv3,tv4,tv5;
public int mPercentRemaining, mPercentTotal, mPercentUsed;
public int mCurrentPercent;
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
sb1=(SeekBar) findViewById(R.id.seekBar1);
sb2=(SeekBar) findViewById(R.id.seekBar2);
sb3=(SeekBar) findViewById(R.id.seekBar3);
sb4=(SeekBar) findViewById(R.id.seekBar4);
sb5=(SeekBar) findViewById(R.id.seekBar5);
tv1=(TextView) findViewById(R.id.textView1);
tv2=(TextView) findViewById(R.id.textView2);
tv3=(TextView) findViewById(R.id.textView3);
tv4=(TextView) findViewById(R.id.textView4);
tv5=(TextView) findViewById(R.id.textView5);
sb1.setOnSeekBarChangeListener(this);
sb2.setOnSeekBarChangeListener(this);
sb3.setOnSeekBarChangeListener(this);
sb4.setOnSeekBarChangeListener(this);
sb5.setOnSeekBarChangeListener(this);
mPercentTotal = 100;
mPercentUsed = 100; //Seekbars are all set to 20% by default
mPercentRemaining = mPercentTotal - mPercentUsed;
}
@Override
public void …Run Code Online (Sandbox Code Playgroud) 如何在android中的异步类中显示FTP下载中的进度条?
我尝试了很多东西,但没有得到进度条.这是我的代码,我从其他Activity调用此类将该活动的上下文传递给此类.
package com.scft;
import it.sauronsoftware.ftp4j.FTPClient;
import it.sauronsoftware.ftp4j.FTPDataTransferListener;
import java.io.File;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.os.StrictMode;
import android.util.Log;
import android.widget.PopupWindow;
import android.widget.Toast;
public class ftpdownload_class {
static final String FTP_HOST= "**************";
/********* FTP USERNAME ***********/
static final String FTP_USER = "*********";
/********* FTP PASSWORD ***********/
static final String FTP_PASS ="*******";
File fileDownload=null;
long startTime_ftpDownload=0;
long endTime_ftpDownload=0;
long downloaded_file=0;
long startTime_ftpUpload=0;
long endTime_ftpUpload=0;
FTPClient client=null;
public static File m_fileName;
private PopupWindow pwindo;
String totaltime_ftpUpload,filesize_ftpUpload,ratevalue_ftpUpload,totaltime_ftpDownload,filesize_ftpDownload,ratevalue_ftp_download;
Context mContext=null;
public ftpdownload_class( Context …Run Code Online (Sandbox Code Playgroud) 我正在尝试在进度条中显示信号强度级别,但我在行中遇到异常: progressBar.setProgress(10);
可能是什么原因?
public class MonAdaptateurDeListe extends ArrayAdapter<ScanResult> {
int pos ;
TextView text;
public MonAdaptateurDeListe(){
super(WiFiScanResult.this,R.layout.item_layout,results);
}
@SuppressLint("DefaultLocale")
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View itemView = convertView;
if (itemView == null){
itemView = getLayoutInflater().inflate(R.layout.item_layout, parent, false);
}
ImageView imageView = (ImageView)itemView.findViewById(R.id.imageView1);
TextView textView4 = (TextView) itemView.findViewById(R.id.level);
imageView.setImageResource(R.drawable.network);
if (results != null)
{
textView4 .setText(results.get(position).level+"dBm");
progressBar = (ProgressBar) findViewById(R.id.progressBar1);
progressBar.setProgress(10);
TextView textView1 = (TextView) itemView.findViewById(R.id.SSIDBssid);
textView1.setText( results.get(position).SSID +"(" + results.get(position).BSSID +")");
TextView textView3 = (TextView) …Run Code Online (Sandbox Code Playgroud) 我在市场上有一个应用程序,我正在添加几个横向ProgressBars.第一个栏正确更新和显示,没有任何问题.第二个栏(相同的代码)在那里,但尽管设置了最大值和进度,但没有显示任何进度.我已经尝试使视图无效(和postInvalidate())没有运气.这是一些瑕疵:
Layout.xml:
<TableRow
android:layout_width="match_parent"
android:gravity="center" >
<TextView
android:id="@+id/tvStorageAName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="0"
android:layout_weight="1"
android:padding="3dp"
android:text="@string/storage_a" />
<TextView
android:id="@+id/tvStorageA"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="1"
android:layout_weight="1"
android:padding="3dp"
android:text="N/A" />
<ProgressBar
android:id="@+id/progBarStorageA"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="0dp"
android:layout_height="8dp"
android:layout_column="2"
android:layout_weight="2"
android:background="@drawable/progbar_bg"
android:indeterminate="false"
android:indeterminateOnly="false"
android:progressDrawable="@drawable/progbar_bg" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:gravity="center" >
<TextView
android:id="@+id/tvStorageBName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="0"
android:layout_weight="1"
android:padding="3dp"
android:text="@string/storage_b" />
<TextView
android:id="@+id/tvStorageB"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="1"
android:layout_weight="1"
android:padding="3dp"
android:text="N/A" />
<ProgressBar
android:id="@+id/progBarStorageB"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="0dp"
android:layout_height="8dp"
android:layout_column="2"
android:layout_weight="2"
android:background="@drawable/progbar_bg"
android:indeterminate="false"
android:indeterminateOnly="false"
android:progressDrawable="@drawable/progbar_bg" />
</TableRow>
Run Code Online (Sandbox Code Playgroud)
这里是我用于在ProgressBars上设置setProgress和Max的代码 Fragment
Fragment.java:
progA = (ProgressBar) getView().findViewById(R.id.progBarStorageA);
progB …Run Code Online (Sandbox Code Playgroud) 我有一个加载屏幕,它有一个微调进度条,它在我的android工作室模拟器上旋转,在Nexus 6 23api上运行.此外,我尝试使用我朋友的Redmi 2并且微调器正在工作.但是旋转器在我的手机galaxy s5 android 5.0上保持静态(不旋转).请帮忙
进度条的布局文件
<ProgressBar
android:id="@+id/progressBar"
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:indeterminate="true"
android:indeterminateDrawable="@drawable/loading_bar"
android:layout_below="@+id/loading_mod_logo"
android:layout_marginTop="20dp"/>
Run Code Online (Sandbox Code Playgroud)
加载屏幕java代码
public class LoadingScreen extends AppCompatActivity {
private ProgressBar spinner;
private boolean registered = false;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_loading_screen);
//spinner is loading bar at loading screen
spinner=(ProgressBar)findViewById(R.id.progressBar);
Run Code Online (Sandbox Code Playgroud) 通过Web服务进行后台工作时,我正在使用此库作为进度指示器。我想在进度条显示时使背景透明。有什么方法可以像在进度对话框中一样以编程方式使窗口透明吗?
public class MainActivity extends AppCompatActivity{
private EditText email, pass;
private SessionManager session;
private SQLiteHandler db;
private AVLoadingIndicatorView pb;
private static final String LOGIN = "http://ubooktoday.com/android/login";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
email = (EditText)findViewById(R.id.et1);
pass = (EditText)findViewById(R.id.et2);
session = new SessionManager(getApplicationContext());
db = new SQLiteHandler(getApplicationContext());
pb = new AVLoadingIndicatorView(this);
if (session.isLoggedIn()) {
startActivity(new Intent(MainActivity.this, ListVActivity.class));
finish();
}
}
public void login(View view){
if (!email.getText().toString().equals("") && !pass.getText().toString().equals("")) {
loginRequest();
}else{
Toast.makeText(getApplicationContext(), "Please enter the details", Toast.LENGTH_SHORT).show(); …Run Code Online (Sandbox Code Playgroud)通过使用 android 实现 Facebook 登录,我需要将令牌发送到我的后端服务器,所以我想知道是否可以删除进度条并创建我自己的进度,在获取 Facebook 令牌并发送到我的服务器后处理。当我打电话时它出现:
LoginManager.getInstance().logInWithReadPermissions(Login.this,Arrays.asList("email"));
Run Code Online (Sandbox Code Playgroud) 我正在使用谷歌数字墨水进行手写识别。需要下载一次的模型大小为20MB,下载需要一些时间。有没有办法使用进度条显示下载进度?
我的代码如下:
fun download(context: Context) {
var modelIdentifier: DigitalInkRecognitionModelIdentifier? = null
try {
modelIdentifier =
DigitalInkRecognitionModelIdentifier.fromLanguageTag(lang)
} catch (e: MlKitException) {
// language tag failed to parse, handle error.
}
model = DigitalInkRecognitionModel.builder(modelIdentifier!!).build()
val remoteModelManager = RemoteModelManager.getInstance()
remoteModelManager.download(model, DownloadConditions.Builder().build())
.addOnSuccessListener {
Log.i("StrokeManager", "Model downloaded")
Toast.makeText(context, "Model Downloaded", Toast.LENGTH_SHORT).show()
}
.addOnFailureListener { e: Exception ->
Log.e("StrokeManager", "Error while downloading a model: $e")
Toast.makeText(context, "Model Download Failed", Toast.LENGTH_SHORT).show()
}
}
Run Code Online (Sandbox Code Playgroud)