小编Tai*_*Dao的帖子

片段中的runOnUiThread

我正在尝试将Activity转换为片段.错误标记打开runOnUiThread.在过去:

GoogleActivityV2从Activity扩展而来.类ExecuteTask中的runOnUiThread.class ExecuteTask嵌套在activity上.

(运行确定)现在:

GoogleActivityV2从Fragment扩展而来.类ExecuteTask中的runOnUiThread.class ExecuteTask嵌套在activity上.(runOnUiThread出错)

这是我的代码

public class GoogleActivityV2 extends SherlockMapFragment implements OnMapClickListener , OnMapLongClickListener , OnCameraChangeListener , TextWatcher {


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState){
        View rootView = inflater.inflate(R.layout.activity_googlev2, container, false);
        Init();
        adapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_dropdown_item_1line);
        textView = (AutoCompleteTextView) getView().findViewById(R.id.autoCompleteTextView1);
        return rootView;
    }

    public void onCameraChange(CameraPosition arg0){
        // TODO Auto-generated method stub
    }

    public void onMapLongClick(LatLng arg0){
        llLoc = arg0;
        stCommand = "onTouchEvent";
        lp = new ExecuteTask();
        lp.execute();
    }

    public void onMapClick(LatLng …
Run Code Online (Sandbox Code Playgroud)

android android-fragments android-activity

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

Android Studio无法通过SVN进行身份验证

我是Android Studio的新手.我正在尝试导入我的项目并使用android studio的内置svn.

当我将项目导入android studio时,它工作正常,但是当我更新,提交时,android工作室的svn无法进行身份验证...

身份验证对话框重复出现.

我做了什么:

  1. 使用TortoiseSVN从svn服务器导入项目文件夹

  2. 将项目导入eclipse并将其导出为Gradle(因为SVN上的项目是eclipse项目)

  3. 将gradle项目导入Android Studio

我的SVN服务器是'svn + ssh'connect.当我尝试更新或提交时,Android Studio无法进行身份验证.

错误:

svn: E204899: E170012: When using svn+ssh:// URLs, keep in mind that the --username and --password options are ignored because authentication is performed by SSH, not Subversion
svn: E170012: Unable to connect to a repository at URL 'svn+ssh://zuranai.arx-project.com/opt/SVN1.zap_dev/trunk/android'
svn: E170012: Can't create tunnel
svn: E720002: Can't create tunnel: The system cannot find the file specified.
Run Code Online (Sandbox Code Playgroud)

我的android工作室有什么问题?有什么建议?

编辑:
我不能提交,更新,但仍然可以还原.

在此输入图像描述

svn tortoisesvn android intellij-idea android-studio

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

如何获得所选国家的国定假日

我正在编写一个允许用户从列表中选择国家/地区的应用.当他们选择一个国家时,会出现该国家的国家法定假日列表.

我见过CalendarProviderGoogle Calendar V3,但它们似乎只提供当前用户的日历.

我怎样才能获得特定国家的国定假日?任何建议都会对我有所帮助.


更新:

我发现这篇文章可以获得JSON格式的假期列表.在此示例中,国家/地区代码由日历ID定义,例如pt_br.brazilian#holiday@group.v.calendar.google.com或en.usa#holiday@group.v.calendar.google.com.

但我找不到任何关于此的文件.是否可以这种方式使用API​​?如果是,我在哪里可以获得这些日历ID?

android calendar google-calendar-api android-calendar

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

上传进度监听器未被触发(Google drive API)

我想使用Google Drive API按上传文件的百分比显示进度.

我的menthod之前成功上传了一个文件,但它看不到上传进度.

我已经看到并添加了这个FileUploadProgressListener,mediaHttpUploader.getProgress()只显示0.0(进度开始)和1.0(进度完成时).我无法及时获得进步百分比.

如何使它工作?

这是我的上传代码:

public void UploadFile(final DFile uploadFile) {
    if (!isLoggedIn()) {
        OnUploadGoogleChecked(FALSE, "Not logged in");
        return;
    }
    AsyncTask<Void, Long, String> task = new AsyncTask<Void, Long, String>() {
        java.io.File fileContent;
        FileContent mediaContent;
        com.google.api.services.drive.model.File body;
        com.google.api.services.drive.model.File file;
        private ProgressDialog mDialog;
        long mFileLen;

        @Override
        protected void onPreExecute() {
            // TODO Auto-generated method stub
            super.onPreExecute();
            mDialog = new ProgressDialog(act);
            mDialog.setMax(100);
            mDialog.setMessage("Uploading ");
            mDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
            mDialog.setProgress(0);
            mDialog.setButton("Cancel", new OnClickListener() {

                @Override
                public void onClick(DialogInterface arg0, int arg1) …
Run Code Online (Sandbox Code Playgroud)

java android progressdialog google-drive-api

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

缩略图不会立即刷新

我正在制作一个文件管理器,其中图片项目有一个小缩略图.

我通过使用获得缩略图MediaStore.一切正常.但是当我重命名或移动文件时,缩略图不会显示.

我找到了一段要刷新的代码MediaStore:

getActivity().sendBroadcast(
  new Intent(Intent.ACTION_MEDIA_MOUNTED, 
             Uri.parse("file://" + Environment.getExternalStorageDirectory())));
Run Code Online (Sandbox Code Playgroud)

它工作但我必须等待4或5秒并刷新,然后缩略图更新.

重命名或移动后如何立即获取图像缩略图?

android thumbnails mediastore

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

将ActionBarSherlock与Google Maps API V2一起使用

我想将ActionBarSherlock与Google map API V2一起使用.我在这里读过一个解决方案.但是当扩展我的主ActionBarSherlock类时,它缺少了很多用于menthod的lib(比如:findViewById,getSupportActionBar ..)

这是我的ActionBarSherlock

public class FeatureToggles extends SherlockMapFragment  {
    private static final Random RANDOM  = new Random();
    private int                         items       = 0;

    @Override
    public boolean onCreateOptionsMenu(Menu menu){
        for(int i = 0; i < items; i++) {
            menu.add("Text").setIcon(R.drawable.ic_title_share_default).setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
        }
        return super.onCreateOptionsMenu(menu);
    }

    @Override
    public void onCreate(Bundle savedInstanceState){
        setTheme(R.style.Theme_Sherlock); // Used for theme switching in samples
        requestWindowFeature(Window.FEATURE_PROGRESS);
        requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
        super.onCreate(savedInstanceState);
        setContentView(R.layout.feature_toggles);
        setSupportProgressBarIndeterminateVisibility(false);
        setSupportProgressBarVisibility(false);
        getSupportActionBar().setCustomView(R.layout.custom_view);
        getSupportActionBar().setDisplayShowCustomEnabled(false);
        Context context = getSupportActionBar().getThemedContext();
        ArrayAdapter<CharSequence> listAdapter = ArrayAdapter.createFromResource(context, R.array.locations, R.layout.sherlock_spinner_item);
        listAdapter.setDropDownViewResource(R.layout.sherlock_spinner_dropdown_item); …
Run Code Online (Sandbox Code Playgroud)

android actionbarsherlock actionbarsherlock-map google-maps-android-api-2

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

从谷歌帐户获取用户名,头像

我正在开发一个使用GoogleAccountCredential登录,上传和下载文件到GoogleDrive的模块.

我希望获得用户的第一个,姓氏和谷歌帐户的头像,以便在我的登录功能上显示.

我试过了

 GoogleAccountCredential.getAccountName()
Run Code Online (Sandbox Code Playgroud)

但它只返回帐户名称.

看看OAuth 2.0但不确定它能提供我需要的东西.

不知道从哪里获得这些信息,任何建议也对我有所帮助.如果有一些例子,那真是太棒了

android google-account google-drive-api google-oauth

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

片段中的setContentView

我正在尝试将Activity转换为片段.setContentView上的错误标记.

这是我的代码

public void onCreate(Bundle savedInstanceState){
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_googlev2);
    Init();
    addMarkersToMap();
    yStart = 21.102918;
    yEnd = 20.960798;
    xStart = 105.772762;
    xEnd = 105.900650;
    xNow = xStart;
    yNow = yStart;
    adapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_dropdown_item_1line);
    textView = (AutoCompleteTextView) getView().findViewById(R.id.autoCompleteTextView1);
    textView.setThreshold(3);
    adapter.setNotifyOnChange(true);
    textView.setAdapter(adapter);
    textView.addTextChangedListener(new TextWatcher() {
        public void onTextChanged(CharSequence s, int start, int before, int count){
            autoCount = count;
            autoS = s;
            if(autoCount % 3 == 1) {
                stCommand = "AutoCompleteTextView";
                lp = new ExecuteTask();
                lp.execute();
            }
        }
        public void beforeTextChanged(CharSequence s, int …
Run Code Online (Sandbox Code Playgroud)

android android-fragments android-activity

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

从左向右移动图像然后旋转动画

我是一个例子,从左到右移动图像然后自己旋转.我尝试过使用AnimationSet,但图像旋转不正确.它在一个循环中移动而不是自我.如何解决这个问题?

我想要的是 在此输入图像描述 主要活动

@Override
protected void onCreate(Bundle savedInstanceState){
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    AnimationSet set = new AnimationSet(true);
    set.setFillAfter(true);
    img_animation = (ImageView) findViewById(R.id.imgBanner);
    Animation rotation = AnimationUtils.loadAnimation(this, R.anim.rotation);
    rotation.setStartOffset(2000);
    rotation.setDuration(2000);
    TranslateAnimation moveLefttoRight = new TranslateAnimation(0, 200, 0, 0);
    moveLefttoRight.setStartOffset(1000);
    moveLefttoRight.setDuration(1000);
    set.addAnimation(moveLefttoRight);
    set.addAnimation(rotation);
    img_animation.startAnimation(set);
}
Run Code Online (Sandbox Code Playgroud)

Rotation.xml

<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
    android:duration="1000"
    android:fromDegrees="0"
    android:interpolator="@android:anim/linear_interpolator"
    android:pivotX="50%"
    android:pivotY="50%"
    android:toDegrees="90" />
Run Code Online (Sandbox Code Playgroud)

activity_main.xml中

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".MainActivity" >

    <ImageView
        android:id="@+id/imgBanner"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/banner" />

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

任何建议对我都有帮助

android android-animation

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

在移动动画时变换ImageView(保持比例)

我正在制作一个动画,一个视图移动并同时将其转换为另一种形式.

这是动画描述:

动画预期

我不知道怎么做.对我有什么解决方案?
任何建议表示赞赏.

================================================== ===============
更新

我用AnimationSet尝试了TranslateAnimation + ScaleAnimation,但我的ImageView缩放得非常难看.

这是使用centerCrop的开始图像:
在此输入图像描述

这是Translate + ScaleAnimation的结果:
在此输入图像描述

但这是我想要的结果(centerCrop上面有相同的src):
在此输入图像描述

如何转换+移动但保持像这样的图像比例?我不希望我的图像比例发生变化.

感谢帮助.

animation android view android-animation android-imageview

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

使用Java从GoogleDrive获取列表文件

我正在开发一个可以从Google云端硬盘登录,下载,上传和显示列表文件的应用.

JavaGoogle Drive SDK中找到了代码,但运行速度很慢,无法正常工作.

我正在阅读解决方案,但不知道在哪里更改范围

我的主要活动:

        // google
        static final int REQUEST_ACCOUNT_PICKER = 1;
        static final int REQUEST_AUTHORIZATION = 2;
        static final int CAPTURE_IMAGE = 3;
        private GoogleAccountCredential credential;
        private static Uri fileUri;
        private static Drive service;

        public void onLoginGoogle(View v) {
                credential = GoogleAccountCredential.usingOAuth2(this, DriveScopes.DRIVE);
                startActivityForResult(credential.newChooseAccountIntent(), REQUEST_ACCOUNT_PICKER);
        }

        public void onUploadGoogle(View v) {
                Thread t = new Thread(new Runnable() {
                        @Override
                        public void run() {
                                try {
                                        // File's binary content
                                        java.io.File fileContent …
Run Code Online (Sandbox Code Playgroud)

java android google-drive-api

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

自定义ImageView中的InflateException

我正在做一个像这篇文章一样旋转图像的例子.
我扩展了ImageView,然后重写OnDraw并放入MainActivity.但它解雇了"InflateException".这是我的示例代码:
MImageView

public class MImageView extends ImageView {

    public MImageView(Context context) {
        super(context);
        // TODO Auto-generated constructor stub
    }

    @Override
    protected void onDraw(Canvas canvas) {
        // TODO Auto-generated method stub
        canvas.save();
        canvas.rotate(45, 0, 0);
        super.onDraw(canvas);
        canvas.restore();
    }
}
Run Code Online (Sandbox Code Playgroud)

主要活动

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        MImageView mImageView = (MImageView) findViewById(R.id.imageView1);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if …
Run Code Online (Sandbox Code Playgroud)

android android-imageview

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