小编moh*_*eri的帖子

android- Gradle:配置根项目android studio时出现问题

我从eclipse迁移到android studio.我创建了一个新项目,我想在genymotion上运行它.当我按下运行图标时,它开始编译并给我这个错误:

Error:Gradle: A problem occurred configuring root project 'Khabar'.
> Could not resolve all dependencies for configuration ':classpath'.
   > Could not resolve com.android.tools.build:gradle:1.1.0.
     Required by:
         :Khabardar:unspecified
      > Could not GET 'https://jcenter.bintray.com/com/android/tools/build/gradle/1.1.0/gradle-1.1.0.pom'.
         > d29vzk4ow07wi7.cloudfront.net
Run Code Online (Sandbox Code Playgroud)

这是我的build.gradle的一些部分:

    apply plugin: 'com.android.application'

android {
    compileSdkVersion 20
    buildToolsVersion "20.0.0"

    defaultConfig {
        applicationId "example.ir.khabar"
        minSdkVersion 8
        targetSdkVersion 20
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

root中的build.gradle:

    apply plugin: 'com.android.application'

android {
    compileSdkVersion 20
    buildToolsVersion "20.0.0"

    defaultConfig …
Run Code Online (Sandbox Code Playgroud)

android

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

mysql - 按字段顺序无法正常工作

假设我有一个数据库,该表包含ide为1到20的行.

我想先返回ID为3,4,1的3行,然后返回其他行.这是我的代码:

    SELECT id
FROM prod
ORDER BY field( id, 3, 4, 1 ) 
LIMIT 20
Run Code Online (Sandbox Code Playgroud)

这是此代码的结果:

id
13 
17 
16 
15 
 7 
 6 
 5 
 2 
 3 
 4 
 1
Run Code Online (Sandbox Code Playgroud)

奇怪的是,我需要先出现的3行最后显示,

如何将这3行添加到列表顶部?

谢谢

php mysql

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

android - 如何为viewPager设置动画

这是我的制作代码ViewPager.我想在更改页面之间进行动画制作.所以我写这段代码:

ViewPagerAdapter adapter;
                adapter = new ViewPagerAdapter(FistActiivty.this,imges);
                vp.setAdapter(adapter);
                pageSwitcher(2);

try {
                    Field mScroller;
                    mScroller = ViewPager.class.getDeclaredField("mScroller");
                    mScroller.setAccessible(true); 
                    Interpolator sInterpolator = new AccelerateInterpolator();
                    FixedSpeedScroller scroller = new FixedSpeedScroller(vp.getContext(), sInterpolator);
                    // scroller.setFixedDuration(5000);
                    mScroller.set(vp, scroller);
                } catch (Exception e) {
                    Log.v("this",e.getMessage());
                }

public class FixedSpeedScroller extends Scroller {

        private int mDuration = 2000;

        public FixedSpeedScroller(Context context) {
            super(context);
        }

        public FixedSpeedScroller(Context context, Interpolator interpolator) {
            super(context, interpolator);
        }

        public FixedSpeedScroller(Context context, Interpolator interpolator, boolean flywheel) {
            super(context, interpolator, flywheel);
        }

        @Override …
Run Code Online (Sandbox Code Playgroud)

android android-viewpager

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

android - FloatingActionButton无法启动活动ComponentInfo

我想在我的应用程序中使用浮动操作按钮,为此我获得了最新的支持库22.2.1并将其作为库添加到我的应用程序中.我清理了项目,没有更多的错误.然后我把这个代码放在我的xml布局中,但是当我运行我的应用程序时,我遇到了一个我无法解决的错误.

这是我的xml代码:

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:padding="4dp" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical" >
        <android.support.design.widget.FloatingActionButton
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom"
            android:layout_margin="16dp"
            android:clickable="true"
            android:src="@drawable/ic_action_person" />
    </LinearLayout>

</ScrollView>
Run Code Online (Sandbox Code Playgroud)

这不是整个代码,我在linearlayout中有一些其他的视图,最后我放了FloatingActionButton.

当我运行我的应用程序时,我收到此错误:

   FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.karaj.project/com.karaj.project.FistActiivty}: android.view.InflateException: Binary XML file line #301: Error inflating class android.support.design.widget.FloatingActionButton
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2211)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
    at android.app.ActivityThread.access$600(ActivityThread.java:141)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:137)
    at android.app.ActivityThread.main(ActivityThread.java:5103)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:525)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
    at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file …
Run Code Online (Sandbox Code Playgroud)

android

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

如何在Android中点击通知时打开浏览器?

这是我的代码,我想在用户点击通知时打开一个 URL。

这是代码:

Intent notificationIntent = new Intent(Intent.ACTION_VIEW);
notificationIntent.setData(Uri.parse(link));

Notification myNotification = new NotificationCompat.Builder(ctx)
                    .setSmallIcon(R.drawable.ic_launcher)
                    .setAutoCancel(false)
                    .setLargeIcon(remote_picture)
                    .setContentTitle(onvan)
                    .setContentIntent(notificationIntent)
                    .setContentText(msg)
                    .setStyle(notiStyle)
                    .build();
notificationManager.notify(1, myNotification);
Run Code Online (Sandbox Code Playgroud)

我收到此错误:setContentIntent(PendingIntent)类型中的方法NotificationCompat.Builder不适用于参数(意图)

我究竟做错了什么?当用户单击通知时,如何告诉它打开浏览器?

android

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

从聊天服务器向Android发送聊天消息的好方法是什么?

我正在编写一个包含聊天系统的应用程序.我正处于一个需要为我的用户聊天的阶段.我有一个服务器端应用程序存储消息很好,但我不知道从Android设备与它通信的最佳方式是什么?

我的应用程序如何知道新数据的最大延迟,例如一秒钟?我是否需要每秒询问服务器,或者是否有任何其他方式通知应用程序已发送新消息,然后调用服务器获取数据.

你有建议如何构建消息吗?我的意思是可能会有很多聊天同时进行.

您认为解决此问题的最佳方法是什么?

谢谢

notifications android

0
推荐指数
1
解决办法
361
查看次数

标签 统计

android ×5

android-viewpager ×1

mysql ×1

notifications ×1

php ×1