小编use*_*732的帖子

Material Design progressdialog

 alertDialog = new ProgressDialog(this);                          
 alertDialog.setMessage(getResources().getString(R.string.loader));
 alertDialog.setCancelable(false);
 alertDialog.show();
Run Code Online (Sandbox Code Playgroud)

简单地说,当我这样做时,绿色圆圈显示除了它之外的单词loading.但是,当我不使用进度对话框,并且我在页面上使用进度条时,我得到一个粉红色,因为我在styles.xml中定义了以下内容

<item name="colorPrimary">@color/pink</item>
<item name="colorPrimaryDark">@color/pink</item>
<item name="colorAccent">@color/pink</item>
Run Code Online (Sandbox Code Playgroud)

获取圆形粉红色的解决方案是什么,如页面上的进度条?

android material

15
推荐指数
1
解决办法
2万
查看次数

每隔2分钟调度一次警报

在我的活动课上

protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        AlarmManager alarmManager=(AlarmManager) getSystemService(ALARM_SERVICE);
        Intent intent = new Intent(MainActivity.this, AlarmReceiver.class);
        PendingIntent pendingIntent = PendingIntent.getBroadcast(MainActivity.this, 0, intent, 0);
        alarmManager.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,System.currentTimeMillis(),2000, pendingIntent);

    }
Run Code Online (Sandbox Code Playgroud)

我的onrecieve功能在alarmreciever类

     @Override
     public void onReceive(Context context, Intent intent)
      {   
        //get and send location information
         System.out.println("fired");
      }
Run Code Online (Sandbox Code Playgroud)

我正在使用nexus 4,kitkat版本.我没有看到每2分钟发射任何一个接收函数.正在发生...任何帮助?谢谢

 <?xml version="1.0" encoding="utf-8"?>
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.alarmexample"
android:versionCode="1"
android:versionName="1.0" >
Run Code Online (Sandbox Code Playgroud)
<uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="20" />

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name" >
    <activity
        android:name=".MainActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <receiver
        android:name="com.example.AlarmExample"
        android:exported="false" > …
Run Code Online (Sandbox Code Playgroud)

android alarms

9
推荐指数
1
解决办法
2万
查看次数

用不同的边框颜色Android绘制圆圈

public static Bitmap drawCircle(int width,int height, int borderWidth) {
    Bitmap canvasBitmap = Bitmap.createBitmap( width, height, Bitmap.Config.ARGB_8888);
    BitmapShader shader = new BitmapShader(canvasBitmap, TileMode.CLAMP,      
            TileMode.CLAMP);
    Paint paint = new Paint();
    paint.setAntiAlias(true);
    paint.setShader(shader);
    paint.setShader(null);
    paint.setStyle(Paint.Style.STROKE);
    paint.setColor(Color.WHITE);
    paint.setStrokeWidth(borderWidth);  
    Canvas canvas = new Canvas(canvasBitmap);
    float radius = width > height ? ((float) height) / 2f : ((float) width) / 2f;
    canvas.drawCircle(width / 2, height / 2, radius - borderWidth / 2, paint);
    return canvasBitmap;
}
Run Code Online (Sandbox Code Playgroud)

简单的这个代码绘制一个带有白色边框的圆圈,但是我希望边框的一部分是黑色而另一部分是白色的.40%的黑色,60%的白色

如何才能做到这一点?

android

7
推荐指数
2
解决办法
1万
查看次数

如何在ANDROID中获得屏幕宽度dpi?

如何获得屏幕宽度dpi?

DisplayMetrics metrics = getResources().getDisplayMetrics();
int f = metrics.densityDpi;


  //  getWindowManager().getDefaultDisplay().getMetrics(metrics);

int width = metrics.widthPixels;
int dp = (int)(width / (metrics.density));
Run Code Online (Sandbox Code Playgroud)

我这样做,所以让我假设我的densitydpi是120 ..和widthpixel 240 ..通过计算得到240/0.75 ....所以我有320宽度?

然而情况并非如此......我认为widthdpi小于320 ...因为320在屏幕上跟我错了....使用120个作品.

在Nexus 4上......宽度为768,密度为320 ......我除以768/2,得到384正确的宽度密度dpi(它可以工作)

但在其他像240,160,120密度dpi ... widthdpi的计算似乎是错误的...

android screen width

6
推荐指数
1
解决办法
1万
查看次数

android棒棒糖通知白色空圈

我这样做了

              Notification.Builder notificationBuilder = new Notification.Builder(
                            getApplicationContext());
                    RemoteViews mContentView = new RemoteViews(
                            getApplicationContext().getPackageName(),
                            R.layout.custom_notification);
                    Uri alertSound = RingtoneManager
                            .getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
                    notificationBuilder.setSound(alertSound);
                    mContentView.setTextViewText(R.id.text, getResources()
                            .getString(R.string.activation_code)
                            + ": "
                            + mUUID);
                    notificationBuilder.setContent(mContentView);
                    notificationBuilder.setContentTitle(getResources()
                            .getString(R.string.activation_code));
                    notificationBuilder
                            .setSmallIcon(R.drawable.ic_launcher);
                    notificationBuilder.setAutoCancel(true);
                    NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
                    manager.notify(11151990,
                            notificationBuilder.getNotification());
Run Code Online (Sandbox Code Playgroud)

非常简单,直到今天我的棒棒糖操作系统为nexus 7完美运行.顶部的通知图标显示白色圆圈.我该怎么办?当我从顶部拖动时,通知内部看起来正常.

notifications android

6
推荐指数
1
解决办法
1111
查看次数

OKHttp 添加标头

final SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(mContext);
            final OkHttpClient okHttpClient = new OkHttpClient.Builder()
                    .addInterceptor(new Interceptor() {
                        @Override
                        public okhttp3.Response intercept(Interceptor.Chain chain) throws IOException {
                            Request.Builder ongoing = chain.request().newBuilder();
                            ongoing.addHeader("Cache-Control", "no-cache");
                            ongoing.addHeader("User-Agent", System.getProperty("http.agent"));
                            ongoing.addHeader("authorization", sharedPreferences.getString("api_key",""));
                            return chain.proceed(ongoing.build());
                        }
                    })
                    .build();
            new Picasso.Builder(mContext).downloader(new OkHttp3Downloader(okHttpClient)).build().with(mContext).load(event.getPictureUrl()).into(holder.eventimage);
Run Code Online (Sandbox Code Playgroud)

我正在使用 com.squareup.picasso:picasso:2.5.2, com.jakewharton.picasso:picasso2-okhttp3-downloader:1.1.0com.squareup.okhttp3:okhttp:3.4.1 并且它没有在标头中发送任何内容。如何解决这个问题?

一旦我添加了这个 Picasso.setSingletonInstance(picasso); 后来我使用了毕加索,它起作用了。

android picasso okhttp

5
推荐指数
1
解决办法
6800
查看次数

Progressbar android里面有文字

我有一个循环ProgressBar,我想要在这个圆形栏内,以百分比写出进展(如60%,或70%..)
我怎么能在圆形内做到这一点ProgressBar

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/RelativeLayout1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

        <ProgressBar
            android:id="@+id/progressBars"
            android:layout_width="200dp"
            android:layout_height="200dp"
            android:layout_centerInParent="true"
            android:layout_centerHorizontal="true"
            android:layout_marginBottom="20dp"
            android:indeterminate="false"
            android:indeterminateDrawable="@drawable/progress_bar"
            android:max="100" />
    </RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

android android-progressbar

4
推荐指数
1
解决办法
3万
查看次数

运行我的应用程序时Android Studio出错

我正在努力研究android studio上的新应用程序,我曾经在e上工作

 UNEXPECTED TOP-LEVEL EXCEPTION:
  com.android.dex.DexIndexOverflowException: method ID not in [0,          
  0xffff]: 65536
at com.android.dx.merge.DexMerger$6.updateIndex(DexMerger.java:484)
at    com.android.dx.merge.DexMerger$IdMerger.mergeSorted(DexMerger.java:261)
   Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
 com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/bin/java'' finished with non-zero exit value 2
Run Code Online (Sandbox Code Playgroud)

这个错误会是什么?

我已经将一些jar文件移动到了我的日食中.而我的build.gradle就是这样的

   apply plugin: 'com.android.application'
     android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
    applicationId "com.netvariant.heinz"
    minSdkVersion 14
    targetSdkVersion 21
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'),     'proguard-rules.pro'
    }
}}dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:design:23.1.1'
compile 'com.google.android.gms:play-services:8.4.0'}
Run Code Online (Sandbox Code Playgroud)

java android

4
推荐指数
1
解决办法
3万
查看次数

在android圈内绘制文字

public static Bitmap drawCircle(int width,int height, int borderWidth) {
    Bitmap canvasBitmap = Bitmap.createBitmap( 350, 350, Bitmap.Config.ARGB_8888);
    BitmapShader shader = new BitmapShader(canvasBitmap, TileMode.CLAMP, TileMode.CLAMP);
    Paint paint = new Paint();
    paint.setAntiAlias(true);
    paint.setShader(shader);
    paint.setShader(null);
    paint.setStyle(Paint.Style.STROKE);
    paint.setColor(Color.WHITE);
    paint.setStrokeWidth(borderWidth);

    Paint paint1 = new Paint();
    paint1.setAntiAlias(true);
    paint1.setShader(shader);
    paint1.setShader(null);
    paint1.setStyle(Paint.Style.STROKE);
    paint1.setColor(Color.WHITE);
    paint1.setStrokeWidth(borderWidth); 
    Canvas canvas = new Canvas(canvasBitmap);
    float radius = width > height ? ((float) height) / 2f : ((float) width) / 2f;
    //canvas.drawCircle(width / 2, height / 2, radius - borderWidth / 2, paint);
    final RectF …
Run Code Online (Sandbox Code Playgroud)

geometry android

3
推荐指数
1
解决办法
1万
查看次数

如何在Java中将zip文件转换为字节

如何将zip文件转换为字节?

 byte[] ba;
 InputStream is = new ByteArrayInputStream(ba);
 InputStream zis = new ZipInputStream(is);
Run Code Online (Sandbox Code Playgroud)

java zip

3
推荐指数
2
解决办法
9523
查看次数