小编AND*_*849的帖子

导航抽屉在Android上滞后

我遇到了导航抽屉的问题,它太慢了,我正在寻找的解决方案是首先关闭抽屉然后显示活动,但它不起作用,当然我错过了一些东西.

private class DrawerItemClickListener implements ListView.OnItemClickListener {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int posicao, long id) {
            setLastPosition(posicao);
            setFragmentList(lastPosition);
            layoutDrawer.closeDrawer(linearDrawer);
        }
    }

    private OnClickListener userOnClick = new OnClickListener() {
        @Override
        public void onClick(View v) {
            layoutDrawer.closeDrawer(linearDrawer);
        }
    };

    private void setFragmentList(int posicao) {

        FragmentManager fragmentManager = getSupportFragmentManager();
        Fragment fragment = new FragmentViagens();

        switch (posicao) {

            case 0:
                fragmentManager.beginTransaction().replace(R.id.content_frame, fragment).commit();
                break;
            case 1:
                fragmentManager.beginTransaction().replace(R.id.content_frame, new FragmentPedidos()).commit();
                break;
            case 2:
                fragmentManager.beginTransaction().replace(R.id.content_frame, new FragmentClientes()).commit();
                break;

        }

        navigationAdapter.setChecked(posicao, true);
        setTitleFragments(lastPosition);
        navigationAdapter.resetarCheck();
        layoutDrawer.closeDrawer(linearDrawer); …
Run Code Online (Sandbox Code Playgroud)

java android fragmenttransaction navigation-drawer

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

Android Google Map如何检查gps位置是否在圈内

我正在尝试使用用户gps位置检测用户是否在标记的半径内.我有标记的坐标,但我不知道如何计算用户是否在该区域.我试过使用以下内容,但即使当前位置在圈内,我仍然会收到"外部"消息.

public class MapaEscola extends FragmentActivity {

    private GoogleMap googleMap;
    private Serializable escolas;
    private ProgressDialog dialog;
    private Circle mCircle;
    private Marker mMarker;



    @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        getActionBar().setDisplayHomeAsUpEnabled(true);
        getActionBar().setHomeButtonEnabled(true);

        setContentView(R.layout.maps);

        // Loading map
        initilizeMap();

        // Changing map type
        googleMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);

        // Showing / hiding your current location
        googleMap.setMyLocationEnabled(true);

        // Enable / Disable zooming controls
        googleMap.getUiSettings().setZoomControlsEnabled(true);

        // Enable / Disable my location button
        googleMap.getUiSettings().setMyLocationButtonEnabled(true);

        // Enable / Disable Compass icon
        googleMap.getUiSettings().setCompassEnabled(true);

        // Enable / Disable Rotate gesture
        googleMap.getUiSettings().setRotateGesturesEnabled(true);

        // …
Run Code Online (Sandbox Code Playgroud)

gps android google-maps geolocation android-maps-v2

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

尝试使用getChildAt()取消选择视图

我正在使用GridView内部ExpandableListView

我有一个功能,当它被点击时突出显示一个项目,现在我正在尝试实现一个按钮,当按下它时将取消选择所有选定的项目,但它取消选择仅查看最后一个视图

public class GridAdapter extends BaseAdapter {

    private Context mContext;
    private ArrayList<Filhos> child;
    public ArrayList<CadastraEscolas> escola;
    private ArrayList<ArrayList<Filhos>> filhos = new ArrayList();



    public GridAdapter(Context context, ArrayList<CadastraEscolas> groups, ArrayList<Filhos> childValues, int groupPosition) {
        mContext = context;
        child = childValues;
        escola = groups;
        posicaoEscola = groupPosition;


    }


    @Override
    public int getCount() {
        return child.size();
    }

    @Override
    public Object getItem(int position) {
        return position;
    }

    @Override
    public long getItemId(int arg0) {
        return 0;
    }

    @Override
    public View getView(final int …
Run Code Online (Sandbox Code Playgroud)

java android for-loop nullpointerexception android-view

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

键盘重叠EditText点击

在我的片段中,我在scrollview中有一个editText,当我点击它时,我将它设置为打开如下:

getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
Run Code Online (Sandbox Code Playgroud)

它从第一次打开时工作正常,但当我关闭键盘并再次打开它时,它与editText重叠,如何将editText设置为始终在SOFT_INPUT_ADJUST_PAN模式下打开?

XML:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:custom="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/alabaster">

    <TextView
        android:id="@+id/semconexao"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="Verifique sua conexão com a internet"
        android:gravity="center"
        android:layout_marginTop="10dp"
        android:visibility="gone"/>


    <ScrollView
        android:id="@+id/scroll"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_above="@+id/footer">

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

            <RelativeLayout
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:visibility="visible">



                <com.android.volley.toolbox.NetworkImageView
                    android:id="@+id/imageInst"
                    android:layout_width="match_parent"
                    android:layout_height="200dp"
                    android:scaleType="centerCrop"
                    android:visibility="visible" />

                <com.retornar.utils.CircledNetworkImageView
                    android:id="@+id/thumbnail"
                    android:layout_width="@dimen/logo_maior"
                    android:layout_height="@dimen/logo_maior"
                    android:layout_marginLeft="20dp"
                    android:layout_marginTop="100dp"
                    android:adjustViewBounds="true"
                    android:scaleType="centerCrop">

                </com.retornar.utils.CircledNetworkImageView>

                <ImageView
                    android:id="@+id/more"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:src="@drawable/ic_amp"
                    android:visibility="gone"
                    android:layout_alignParentBottom="true"
                    android:layout_alignParentRight="true"
                    android:layout_alignParentEnd="true" />

            </RelativeLayout>


            <TextView
                android:id="@+id/retornarTitulo"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/imageInst"
                android:layout_marginTop="20dp"
                android:gravity="center"
                android:padding="10dp"
                android:text="@string/retornarTitulo"
                android:textColor="@color/armadillo"
                android:textSize="@dimen/text2" /> …
Run Code Online (Sandbox Code Playgroud)

android android-keypad android-edittext android-fragments

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

如何在ArrayList中存储ExpandableListView的选定项

我有一个用户列表ExpandableListView,现在我有2组列表,现在我正在尝试创建一个ArrayList将添加数据,因为我点击用户,所以如果有2组学校,我点击一个每个人的学生我应该在我的阵列中有2个位置,每个组包含其各自的用户一个,我的问题是,我的阵列有2个位置,但它不是分开学生:

我想要的是这个:

学校A:

student1被选中

STUDENT2

student3入选

学校B:

student4

student5入选

结果如下:

[0] - >学生1,3 [1] - >学生5

这是我到目前为止尝试的内容:

mGpsEscolas = new GPSEscolas();
mArrayEscolas = new ArrayList<GPSEscolas>();
aMap = new HashMap<String, GPSEscolas>();

ExpandList.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {
    @Override
    public boolean onChildClick(final ExpandableListView parent, View v, final int groupPosition, final int childPosition, final long id) {
        ExpAdapter.setClicked(groupPosition, childPosition);

        index = parent.getFlatListPosition(ExpandableListView.getPackedPositionForChild(groupPosition, childPosition));
        parent.setItemChecked(index, true);
        parent.setSelectedChild(groupPosition, childPosition, true);
        parent.getChildAt(index);

        IdAlunos = String.valueOf(mMainRest.mArrayList.get(groupPosition).getalunos().get(childPosition).getId_aluno());
        IdEscola = String.valueOf(mMainRest.mArrayList.get(groupPosition).getId_escola());

        ids_alunos.add(IdAlunos);


        notificar.setOnClickListener(new View.OnClickListener() {
            @Override
            public void …
Run Code Online (Sandbox Code Playgroud)

java arrays android arraylist multidimensional-array

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

具有多项选择的ExpandableListView将所选项目保存到数组中

我有一个充满API数据的数组,我有一个expandablelistview来显示该数组的项目,现在我要做的是当用户点击一个项目时它将该项目的ID保存到一个数组中,所以如果用户在我的数组中选择2个我想要2个ID的项目,现在发生的是:无论我是否只选择其中一个项目,它将所有项目保存在我的数组中.

public class MainActivity extends Fragment {

    private ExpandListAdapter ExpAdapter;
    private ExpandableListView ExpandList;
    private Button notificar;
    private Context context;
    MainActivity mContext;
    private Button footer;
    private double RaioEscola;
    private CircleOptions mCircle;
    GPSTracker tracker;
    private Location location;
    private Integer IdEscola;

    public MainActivity() {
    }

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

    @Override
    public View onCreateView(final LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

        final View rootView = inflater.inflate(R.layout.expand, container, false);

        ExpandList = (ExpandableListView) rootView.findViewById(R.id.exp_list);
        notificar = (Button) rootView.findViewById(R.id.btnGetMoreResults);

        new asyncTask(MainActivity.this).execute();

        return rootView; …
Run Code Online (Sandbox Code Playgroud)

arrays android multidimensional-array expandablelistview android-listview

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

ExpandableListView中的GridView,在Android上有多种选择

在我的应用程序中,我需要在expandableListView中显示图像,它必须是图像的网格视图,这些图像可以选择,所以我有一个expandableListAdapter,在其中我正在实现gridview适配器,图像显示正常你可以在图片1中看到,现在我想要实现的是图片2,如何将groupPosition和childPosition传递给gridAdapter,当我点击图像使其突出显示?:

在此输入图像描述

图2: 在此输入图像描述

public class ExpandListAdapter extends BaseExpandableListAdapter {


    public static final int CHOICE_MODE_MULTIPLE = AbsListView.CHOICE_MODE_MULTIPLE;


    public static final int CHOICE_MODE_MULTIPLE_MODAL = AbsListView.CHOICE_MODE_MULTIPLE_MODAL;

    /**
     * No child could be selected
     */
    public static final int CHOICE_MODE_NONE = AbsListView.CHOICE_MODE_NONE;

    /**
     * One single choice per group
     */
    public static final int CHOICE_MODE_SINGLE_PER_GROUP = AbsListView.CHOICE_MODE_SINGLE;

    /**
     * One single choice for all the groups
     */
    public static final int CHOICE_MODE_SINGLE_ABSOLUTE = 10001;

    private Context context;
    private ArrayList<Group> groups;
    private ArrayList<ArrayList<Child>> child = new …
Run Code Online (Sandbox Code Playgroud)

java android gridview expandablelistview

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

Android:Volley HTTP Request自定义标头

运行应用程序时出现以下错误:BasicNetwork.performRequest:意外的响应代码401

我需要传递电子邮件,密码和令牌来访问URL,但它无法正常工作

我上周开始学习android,我不太了解

package quest.testvolley;

import com.android.volley.AuthFailureError;
import com.android.volley.VolleyLog;
import com.kpbird.volleytest.R;

import android.app.ProgressDialog;
import android.os.Bundle;
import android.app.Activity;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ListView;
import android.widget.TextView;
import com.android.volley.Request;
import com.android.volley.RequestQueue;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.JsonObjectRequest;
import com.android.volley.toolbox.Volley;
import org.json.JSONArray;
import org.json.JSONObject;

import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

public class MainActivity extends Activity {

    private String TAG = this.getClass().getSimpleName();
    private ListView lstView;
    private RequestQueue mRequestQueue;
    private ArrayList<NewsModel> arrNews ;
    private LayoutInflater …
Run Code Online (Sandbox Code Playgroud)

android httprequest digest-authentication android-volley

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

使用反应禁止标题访问vuforia vws

我正在尝试使用react + axios调用vuforia的web服务,阅读vuforia的文档,并在我打电话时遵循这些步骤我在chrome的控制台日志中出现错误,即:

xhr.js:121 Refused to set unsafe header "Date"
Run Code Online (Sandbox Code Playgroud)

但如果我理解正确,我必须在请求中声明标题"Date".我该如何解决,这是我的代码:

class App extends Component {
  componentDidMount() {
    var md5 = require('md5');
    var base64 = require('base-64');
    var hmacsha1 = require('hmacsha1');
    var contentType = "application/json";
    var hexDigest = "d41d8cd98f00b204e9800998ecf8427e";
    var accessKey = "xxxxxxxxxxxx";
    var secretKey = "xxxxxxxxxxx";
    var date = new Date().toUTCString();
    var url = `${'https://cors-anywhere.herokuapp.com/'}https://vws.vuforia.com/targets`;
    var dateValue = date;
    var requestPath = url;
    var newLine = '\n';
    var toDigest = `GET${newLine}${hexDigest}${newLine}${contentType}${newLine}${dateValue}${newLine}${requestPath}`;
        var shaHashed = hmacsha1(secretKey, toDigest);

    var signature …
Run Code Online (Sandbox Code Playgroud)

xmlhttprequest vuforia reactjs react-redux

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

NetworkImageView无法从第一次加载图像

我正在尝试从我的API上传图像以将其显示为个人资料图片,问题是从用户第一次打开导航器时图像未加载并且它使整个布局消失,但是从第二次开始这一切都有效,我注意到当图像的宽度小于高度时会发生这种情况.这是我正在使用的类:

public class CircledNetworkImageView extends ImageView {

    public boolean mCircled;

    /**
     * The URL of the network image to load
     */
    private String mUrl;

    /**
     * Resource ID of the image to be used as a placeholder until the network image is loaded.
     */
    private int mDefaultImageId;

    /**
     * Resource ID of the image to be used if the network response fails.
     */
    private int mErrorImageId;

    /**
     * Local copy of the ImageLoader.
     */
    private ImageLoader mImageLoader;

    /**
     * Current …
Run Code Online (Sandbox Code Playgroud)

android imageview navigation-drawer android-volley

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