小编Gau*_*ora的帖子

在长按中将Android中的图标作为iPhone摇动

我正在实现一个应用程序,我想在iPhone中摇动图标.

我该如何实现呢?

我在这里附上了动画的代码.请建议我任何解决方案.我已经尝试了已经在堆栈溢出中指定的soln,但它在我的情况下不起作用.此类是一个非活动类,其中编写了此动画集.

protected void animateDragged(){
    View v = getChildAt(dragged);
    int x = getCoorFromIndex(dragged).x + childSize / 2, y = getCoorFromIndex(dragged).y + childSize / 2;
    int l = x - (3 * childSize / 4), t = y - (3 * childSize / 4);
    v.layout(l, t, l + (childSize * 3 / 2), t + (childSize * 3 / 2));
    AnimationSet animSet = new AnimationSet(true);
    ScaleAnimation scale = new ScaleAnimation(.667f, 1, .667f, 1, childSize * 3 / 4, childSize * …
Run Code Online (Sandbox Code Playgroud)

animation android

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

Android使用Smack添加FRIEND

我是使用smack库和制作一个聊天应用程序的新手.我已经做了很多工作,在这一步我想问两个问题.

  1. 当我添加一个朋友时,朋友已添加到我的列表中,但没有任何通知发送给我已添加的FRIEND,如何实现相同.我在下面添加了代码.

  2. 我要问的第二件事是,我如何检查我要添加的用户是否是应用程序的一部分或成员(意味着它是否在服务器上).因此,不应将未注册到应用程序的用户添加到好友列表中.

这是代码

public static boolean addFriend(String jid) {
            String nickname = null;
            nickname = StringUtils.parseBareAddress(jid);
            RosterEntry entry4 = roster.getEntry("samsad");
            if (!roster.contains(jid)) {
                try {
                    Presence subscribe = new Presence(Presence.Type.subscribe);
                    subscribe.setTo(jid);               
                    connection.sendPacket(subscribe);               
                    roster.createEntry(jid, nickname, null);
                      // Send a roster entry (any) to user2
                    RosterExchangeManager REM = new RosterExchangeManager(connection);
                    REM.send(entry4, jid);
                    return true;
                } catch (XMPPException e) {
                    System.err.println("Error in adding friend");
                    return false;
                }
            } else {
                return false;
            }
        }
Run Code Online (Sandbox Code Playgroud)

在后台运行服务的名册交换经理

/**Remotr Exchange Manager*/
             RosterExchangeManager rem = new …
Run Code Online (Sandbox Code Playgroud)

android livechat smack

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

Android onActivityResult

我陷入困境,根据我的应用程序图表流程描述如下:

假设我在活动A上,在按钮上点击我从图库中选择图像并在选择之后,我将转移到活动B(它来自onActivity结果 - 通过传递Intent).现在,当我在活动B上并单击按钮时,会调用自定义视频制作者.在这里,我捕捉视频10秒,然后我完成(活动C)使用

C.this.finish();
Run Code Online (Sandbox Code Playgroud)

现在根据Android活动流程我应该回到活动B,但在我的情况下,我得到一个黑屏几秒钟,然后获得活动A,而不是活动B.我不能透露我的代码,所以我我没附上它.对不起,同样的.如果有人可以帮我提供这么多信息,请帮助我

码:

单击按钮的活动B代码段:

 btnTakeVideo.setOnClickListener(new OnClickListener() {
            public void onClick(View arg0) {                
                Intent takePictureIntent = new Intent(TakeAnotherPhoto.this,Recorder.class);

                startActivityForResult(takePictureIntent,CreateAuctionScreen.ACTION_TAKE_VIDEO);
            }
        });
Run Code Online (Sandbox Code Playgroud)

这是onActivityResult

onActivityResult()
if(requestCode == CreateAuctionScreen.ACTION_TAKE_VIDEO) {
            if (resultCode == RESULT_OK) {
                if(CreateAuctionScreen.resetBitmap!=null)
                {                
                    CreateAuctionScreen.resetBitmap = null;
                }                
                Drawable dd;
                dd = getResources().getDrawable(R.drawable.list_pic_frame2x);
                CreateAuctionScreen.bmpSize = ((BitmapDrawable)dd).getBitmap();

                if(data != null){


                    Uri str = data.getData();
                    String path = getRealPathFromURI(str);
                    System.out.println(path);

                    Bitmap bmp = ThumbnailUtils.createVideoThumbnail(path, MediaStore.Images.Thumbnails.MINI_KIND);
                    CreateAuctionScreen.resetBitmap = Bitmap.createScaledBitmap(bmp, CreateAuctionScreen.bmpSize.getWidth(), CreateAuctionScreen.bmpSize.getHeight(), true);

                    if(CreateAuctionScreen.resetBitmap != null){

                        if(CreateAuctionScreen.thumbList.size() < 20){
                            dpv.set_chkString("Video");
                            dpv.get_chkString(); …
Run Code Online (Sandbox Code Playgroud)

android video-recording android-activity

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

Android在EditText中检查空格

我在Android中编辑文本有问题.

我有一个名为Username的字段:

我希望每当有人用空格写一个用户名时,例如"Gaurav Arora".然后它应该在按下登录按钮时提出祝酒或错误.

我这样做了 - 我在文本观察者的帮助下简单地停止了空格键的效果 -

public static TextWatcher getNameTextWatcher(final TextView agrTextView) {
        TextWatcher mTextWatcherName = new TextWatcher() {
            public void onTextChanged(CharSequence arg0, int arg1, int arg2,
                    int arg3) {
            }

            public void beforeTextChanged(CharSequence arg0, int arg1,
                    int arg2, int arg3) {
            }

            public void afterTextChanged(Editable arg0) {

                String result = agrTextView.getText().toString().replaceAll(" ", "");
                if (!agrTextView.getText().toString().equals(result)) {
                    agrTextView.setText(result);
                }

}
}
Run Code Online (Sandbox Code Playgroud)

但这并没有解决我的目的.我只是想实现当人们使用带有空格的用户名时它应该接受空间但是在按下登录按钮时它应该举起一个吐司

谢谢

android android-edittext

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

图像不是自动调整

在android中,当我们从库中打开截图时.模糊2秒后自动调整.

但是,当我使用此截图图像在imageview上使用图像路径设置为:,

图像路径为:/mnt/sdcard/ScreenCapture/SC20130219-124221.png

private void showImage(String imgPath) {
        // TODO Auto-generated method stub

        System.out.println("Image Path is:  "+imgPath);

        ImageView openImage=(ImageView)findViewById(R.id.img_fullScreen);
        ExifInterface exifMedia = null;
        try {
            exifMedia = new ExifInterface(imgPath);
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        String exifOrint = exifMedia.getAttribute(ExifInterface.TAG_ORIENTATION);
        int exifOrientation = Integer.parseInt(exifOrint);
        System.out.println("Orientation Tag is:"+exifOrientation);
        BitmapFactory.Options mOptions=new BitmapFactory.Options();
        mOptions.inSampleSize=2;
        Bitmap imgBitmap = BitmapFactory.decodeFile(imgPath,mOptions);
        //Runtime.getRuntime().gc();

        imgBitmap = getResizedBitmapImage(imgBitmap, 200, 200, exifOrientation);
        openImage.setImageBitmap(imgBitmap);
    }
Run Code Online (Sandbox Code Playgroud)

另一种情况:从URL获取位图时:

URL url = new URL(urlTarget);
            BitmapFactory.Options mOptions = new BitmapFactory.Options(); …
Run Code Online (Sandbox Code Playgroud)

android android-imageview

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

当我的应用程序失去焦点并重新获得焦点时,UI 会更新。奇怪的问题

我想更新 aynctask 中的 textView,但它根本没有更新。我无法找出我的错误。

这是我的代码:

注意:- 当我的应用程序失去焦点并重新获得焦点时,UI 会更新。奇怪的问题

public class LocateGeopoint extends AsyncTask<LatLng, String, List<Address>> {

    Geocoder geocoder;
    private TextView tv;

    public LocateGeopoint(View v) {
        this.geocoder = new Geocoder(v.getContext());
        this.tv = (TextView) v.findViewById(R.id.textView1);
    }

    @Override
    protected void onPostExecute(List<Address> addresses) {
        super.onPostExecute(addresses);
        if(addresses!=null){
            String city = addresses.get(0).getAddressLine(0);
            String country = addresses.get(0).getAddressLine(1);
            System.out.println(city+"  "+country);

            tv.setText(city);

        }
    }

    @Override
    protected List<Address> doInBackground(LatLng... params) {
        // TODO Auto-generated method stub
        double lattitude = params[0].latitude;
        double longitude = params[0].longitude;

        List<Address> addresses = null;
        if (lattitude …
Run Code Online (Sandbox Code Playgroud)

android textview android-asynctask google-maps-android-api-2

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

在Android中显示工具提示视图

我想在android中显示一个工具提示类型弹出窗口,在(i)按钮(或视图)上单击,如我在设计中所示.

是否有可能在Android中,我必须显示此工具提示的i按钮已经在弹出窗口中.

谢谢

在此输入图像描述

android popup

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

列表视图中的水平ScrollView项目Android

我有一个包含20行的列表视图,我想为scrollview列表视图中的每个行项设置一个水平,因为每行包含多个项目.

这是我的代码:

<?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="wrap_content"
    android:orientation="horizontal" >

    <HorizontalScrollView
        android:id="@+id/hor_scroll"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:scrollbars="none" >

        <LinearLayout
            android:id="@+id/mainLinear"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="horizontal" >
        </LinearLayout>
    </HorizontalScrollView>

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

内行布局,可以连续多次复制

<ImageView
    android:id="@+id/icon"
    android:layout_width="wrap_content"
    android:layout_height="fill_parent"
    android:layout_marginRight="6.0dip"
    android:src="@drawable/ic_launcher" />

<TextView
    android:id="@+id/text"
    android:layout_width="wrap_content"
    android:layout_height="fill_parent"
    android:gravity="center_vertical"
    android:text="Example Value"
    android:textAppearance="?android:textAppearanceMedium" />
Run Code Online (Sandbox Code Playgroud)

BaseAdapter

public class HorizontalListViewAdapter extends BaseAdapter {

    private Context context;
    private ArrayList<ArrayList<DwivediJi>> dataSet;


    public HorizontalListViewAdapter(Context context) {
        this.context = context;
    }

    @Override
    public int getCount() {
        return 20;
    }

    @Override
    public Object getItem(int arg0) { …
Run Code Online (Sandbox Code Playgroud)

android listview horizontalscrollview

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

嵌套Scrollview + Recycler View

我有一个布局,其中包含可折叠的图像视图,以及布局中的GridView,以及UI中的更多内容.但是屏幕滚动到图像滚动,即它只向上滚动直到标题图像不可见.之后它既不滚动也不滚动.

我怎么解决这个问题?

这是我的布局:

父布局:

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    >

    <android.support.design.widget.AppBarLayout
        android:id="@+id/appBar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:fitsSystemWindows="true"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

        <android.support.design.widget.CollapsingToolbarLayout
            android:id="@+id/collapse_toolbar"
            android:layout_width="match_parent"
            android:layout_height="256dp"
            android:fitsSystemWindows="true"
            app:contentScrim="?attr/colorPrimary"
            app:layout_scrollFlags="scroll|exitUntilCollapsed">

            <ImageView
                android:id="@+id/headerImage"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:fitsSystemWindows="true"
                android:scaleType="centerCrop"
                android:src="@drawable/gallery_shop"
                app:layout_collapseMode="parallax" />

            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                android:gravity="top"
                android:minHeight="?attr/actionBarSize"
                app:layout_collapseMode="pin"
                app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
                app:titleMarginTop="15dp" />

        </android.support.design.widget.CollapsingToolbarLayout>

    </android.support.design.widget.AppBarLayout>


    <android.support.design.widget.FloatingActionButton
        android:id="@+id/fabCall"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="@dimen/fab_margin"
        app:layout_anchor="@id/appBar"
        android:clickable="true"
        app:layout_anchorGravity="bottom|right|end"
        android:src="@drawable/telephone_call" />

    <include
        layout="@layout/content_shop_products_category"/>

</android.support.design.widget.CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud)

包含的布局:

[![<?xml version="1.0" encoding="utf-8"?>

<android.support.v4.widget.NestedScrollView 
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_gravity="fill_vertical"
    android:layout_margin="5dp"
    android:fillViewport="true"
    app:layout_behavior="@string/appbar_scrolling_view_behavior">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <android.support.v7.widget.CardView
            xmlns:android="http://schemas.android.com/apk/res/android" …
Run Code Online (Sandbox Code Playgroud)

android material-design nestedscrollview

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

列表视图/ Recycler视图预加载动画

我想制作一个加载动画,如附带的截图.我无法在网上找到它,或者我可能正在搜索错误的关键字.

有人可以帮我吗?

列表项中的行显示为移动.我正在给出Flipkart App - 我的订单部分的屏幕截图

在此输入图像描述

android listview android-recyclerview

5
推荐指数
2
解决办法
2534
查看次数