我在我的应用程序中添加了一个进度条,但我想在做一些操作后隐藏它,
我用hide(),dismiss()和cancel()......但他们没有工作?
如何隐藏进度条?
渲染问题
Path.approximate()不受支持.
无法解析文件
〜\ SDK \平台\ Android的21\DATA \水库\绘制\ progress_medium_material.xml错误后添加ProgressBar到Layout
怎么解决?
android android-progressbar android-studio material-design android-5.0-lollipop
我有一个GoogleTranslate.java文件,其中包含一个扩展AsyncTask的类GoogleTranslate.此任务的目的是执行Google翻译.
我有另一个类MyVocab,它允许用户在警告对话框中输入要翻译的单词.因此,只需单击警告对话框按钮,即可通过调用GoogleTranslate类将该单词翻译为所需语言.但是,当我将进度条从MyVocab传递到GoogleTranslate时,它不起作用.当操作正在运行时(可观察的时间量),进度条不会显示.我在onPreExecute中将进度条设置为VISIBLE,并在onPostExecute中将其设置为GONE.
我想知道是不是因为我在两个不同的java文件中有GoogleTranslate和MyVocab,因为我看到的大多数示例都有异步类和在同一个java文件中调用它的类.请告诉我,如果有什么我做错了导致这个问题.
这是相关的代码:
GoogleTranslate.java
public class GoogleTranslate extends AsyncTask<String, Void, String>{
private ProgressBar mProgressBar;
public GoogleTranslate(ProgressBar progressBar) {
super();
mProgressBar = progressBar;
}
@Override
protected void onPreExecute() {
mProgressBar.setVisibility(View.VISIBLE);
}
@Override
protected void onPostExecute(String s) {
mProgressBar.setVisibility(View.GONE);
}
@Override
protected String doInBackground(String... params) {
String vocab = params[0];
String source = params[1];
String target = params[2];
String sourceQuery = "";
String targetQuery = "&target=" + target;
// "" means its
if (!source.equals("Detect Language")) {
sourceQuery = "&source=" + source; …Run Code Online (Sandbox Code Playgroud) 我希望列表项的背景像进度条一样工作.例如,在tTorrent文件列表中:
现在就是这样做的:我使用了relativelayout和两个线性输出.一个有textview,另一个有两个视图作为进度条.使用视图的权重更改"进度",这是在getView方法中动态设置的.然后将带有textview的linearlayout放在前面.这是代码:
布局:
<LinearLayout
android:padding="5dp"
android:id="@+id/catStatsRowLay"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<!-- textviews on the front -->
...
</LinearLayout>
<!-- views which work as progress bar -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignBottom="@id/catStatsRowLay"
android:layout_alignLeft="@id/catStatsRowLay"
android:layout_alignRight="@id/catStatsRowLay"
android:layout_alignTop="@id/catStatsRowLay"
android:layout_below="@id/catStatsRowLay"
android:layoutDirection="rtl"
android:orientation="horizontal" >
<View
android:id="@+id/catStatsRowBar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight=".70"
android:background="#cc550000" />
<View
android:id="@+id/catStatsRowBar2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight=".30"
android:background="@android:color/transparent" />
</LinearLayout>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
和getView方法:
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View rowView = inflater.inflate(R.layout.categories_stats_list_row,
parent, false);
//filling textviews
...
//getting bars …Run Code Online (Sandbox Code Playgroud) 我正在检查如何将菜单项的图标更改为进度条加载动画.我试过了
<item android:id="@+id/action_favorite"
android:icon="@drawable/ic_action_heart"
clasificados:showAsAction="always|collapseActionView"
clasificados:actionViewClass="android.widget.ProgressBar"/>
Run Code Online (Sandbox Code Playgroud)
我正在使用分割操作栏模式.当我点击它时,图标消失,进度条显示在顶部栏上.
我需要改变什么?
android android-progressbar android-menu android-actionbar android-actionbar-compat
我有一个循环的进度条,它工作正常.但是背景没有出现,即使我已经在xml可绘制文件中给出了"背景"的形状,并且从圆圈的右侧开始进度(如图所示) ).我希望它从顶部开始.

这是我的代码:
<ProgressBar
android:id="@+id/progressBarToday"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="50dip"
android:layout_height="50dip"
android:layout_centerInParent="true"
android:indeterminate="false"
android:max="60"
android:progress="0"
android:progressDrawable="@drawable/progressbar" />
Run Code Online (Sandbox Code Playgroud)
progressbar.xml
<?xml version="1.0" encoding="UTF-8" ?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@android:id/background"> <---not working!
<shape
android:innerRadiusRatio="3"
android:shape="ring"
android:thicknessRatio="7.0">
<solid android:color="@color/red"/>
</shape>
</item>
<item android:id="@android:id/progress">
<shape
android:innerRadiusRatio="3"
android:shape="ring"
android:thicknessRatio="7.0">
<solid android:color="@color/blue"/>
</shape>
</item>
</layer-list>
Run Code Online (Sandbox Code Playgroud)
我使用以下代码来设置进度:
ProgressBar pb = (ProgressBar)FindViewById (Resource.Id.progressBarToday);
_progressBar.Progress = _progressCount;
Run Code Online (Sandbox Code Playgroud)
为什么没有出现背景?我怎样才能从顶部开始进步?
有人请帮忙,谢谢.
android xamarin.android android-progressbar progress-bar xamarin
我使用下面的代码来更改Indeterminate ProgressBar的颜色.这很有效,直到KitKat.但是在Lollipop上,它只是保持绿色.任何人都可以帮我解决这个问题.我想通过Java而不是XML来实现.
代码:这将微调颜色设置为粉红色
pd.getIndeterminateDrawable().setColorFilter(0xFFeA6060,
android.graphics.PorterDuff.Mode.MULTIPLY);
Run Code Online (Sandbox Code Playgroud) 每当我想在我的应用程序中显示进度条时,我调用此方法,此方法将ProgressBar添加到我的布局中.
问题:我想在Dialog上显示此进度条,但Dialog始终显示在上面.这种情况可以做些什么?
public static void showProgressBar(@NonNull final Activity activity) {
try {
if (activity == null) {
LogManager.printStackTrace(new NullActivityException());
return;
}
View view = activity.findViewById(android.R.id.content);
if (view == null) {
LogManager.printStackTrace(new NullPointerException("content view is null"));
return;
}
View rootView = activity.findViewById(android.R.id.content).getRootView();
if (rootView == null || !(rootView instanceof ViewGroup)) {
LogManager.printStackTrace(new NullPointerException("rootView is null or not an instance of ViewGroup"));
return;
}
final ViewGroup layout = (ViewGroup) rootView;
final ProgressBar progressBar = new ProgressBar(activity);
progressBar.setIndeterminate(true);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) …Run Code Online (Sandbox Code Playgroud) 在将 Android Studio 更新到最新版本后尝试构建项目时,出现此错误。我收到以下错误:
C:\Users\YaCn.gradle\caches\transforms-2\files-2.1\5502c0022567bdcff063e0fb4352b137\folioreader-0.3.3\res\layout\progress_dialog.xml:10: AAPT: 错误/资源栏:androidprogressattr成立。
那个 XML :
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout android:id="@+id/layout_loading"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:gravity="center">
<ProgressBar android:id="@+id/loading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="?android:attr/android:progressBarStyle"/>
<TextView android:id="@+id/label_loading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:textSize="18sp"
android:textColor="@android:color/white"
android:text="@string/loading"/>
</LinearLayout>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
构建gradle文件:
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.example.admin.hashtab"
minSdkVersion 16
targetSdkVersion 27
versionCode 1
versionName "1.0"
multiDexEnabled true
manifestPlaceholders = [manifestApplicationId : "${applicationId}",
onesignal_app_id : "654bcb8c-90a6-4012-924a-e18e5787a7de",
onesignal_google_project_number: "3520309722"]
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles …Run Code Online (Sandbox Code Playgroud) 我正在尝试实现类似于我在Android下面放置的旋转活动.我相信我应该使用ProgressDialog.我的问题源于如何实际操作ProgressDialog看起来像活动指示器.
欢迎任何想法.一个例子的链接甚至会更好.
谢谢.

重新编辑:
myProgress.java
public class myProgress extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ProgressDialog d = (ProgressDialog)findViewById(R.id.progres);
Run Code Online (Sandbox Code Playgroud)
main.xml中
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/progres"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
>
<ProgressBar
android:id="@+id/progressBar"
android:indeterminate="true"
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
/>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud) android ×10
progress-bar ×2
android-menu ×1
android-xml ×1
animation ×1
dialog ×1
rotation ×1
visibility ×1
xamarin ×1