Tag: 安卓

在Android上获取所有文件夹google drive api

我使用新的谷歌驱动器API,我无法从我的谷歌驱动器获取所有文件夹,我只获得我用谷歌驱动器API创建的文件夹…任何人都知道为什么会这样? 这是我的代码: @Override protected void onResume() { super.onResume(); if (mGoogleApiClient == null) { // Create the API client and bind it to an instance variable. // We use this instance as the callback for connection and connection // failures. // Since no account name is passed, the user is prompted to choose. mGoogleApiClient = new […]

Android自定义列表视图

我经历了教程和搜索,但我仍然无法理解, getView(int position, View convertView, ViewGroup arg2) 扩展BaseAdapter在我的Android应用程序中创建自定义listView时,该方法有效。 因此,我无法准确编辑自定义列表视图。 我需要知道这个方法何时调用以及参数的含义。 如果有人能解释下面的方法很棒。 谢谢 @Override public View getView(int position, View convertView, ViewGroup arg2) { ViewHolder holder; LayoutInflater inflater = context.getLayoutInflater(); if (convertView == null) { convertView = inflater.inflate(R.layout.listitem_row, null); holder = new ViewHolder(); holder.txtViewTitle = (TextView) convertView.findViewById(R.id.textView1); holder.txtViewDescription = (TextView) convertView.findViewById(R.id.textView2); convertView.setTag(holder); } else { holder = […]

创建支持不同屏幕尺寸的相同UI?

我目前在android studio中有设计问题。 我想创建在每个设备上应该看起来相同的UI,但现在我不能正确地做到这一点。 我正在使用约束布局,这些是截图: 对于Android屏幕尺寸4.7 UI如下图所示截图: 和Android屏幕7.0大小UI看起来像这个截图: 因为图像显示屏幕尺寸7上的圆形图像非常小, edittext看起来edittext了。 如何在保持视图如屏幕尺寸4.7的同时支持两种或更多屏幕尺寸。

如何获取父节点的值作为字符串?

所以在上面的数据结构中,我想获得Aprilia Caponord 1200价值(在图中标出)。 我有对Aprilia (根节点)的Firebase引用,我可以获取所有键/值对数据。 这是我的代码 @override public void onDataChange(DataSnapshot dataSnapshot) { for (DataSnapshot child : dataSnapshot.getChild()) { Map value = (Map) child.getValue(); String bike_price = value.get(“price”).toString(); String image_url = value.get(“image_url”).toString(); } } 很明显,我可以获得具有键/值关系的子节点的所有值。 但我无法专门获取父节点的名称。 那么如何以String格式获取父节点的值? 如果我打印child.getValue().toString() ,我得到JSON值,但我对解析JSON不感兴趣。 是否有任何特定的方法来获取父节点值? {Aprilia Caponord 1200={image_url=____________, price=18.35}.. }

具有多个选项的Android意图,即使用前置摄像头从gallary中选择图像并捕获图像

选择/捕获图像后,我需要裁剪图像。 我已经完成了这一个。但问题是当我切换到Android最新版本(kitkat)时,作物意图不能正常工作。 我的代码 private void picPhoto() { Intent pickIntent = new Intent(); if (Build.VERSION.SDK_INT < 19) { pickIntent.setType("image/jpeg"); pickIntent.setAction(Intent.ACTION_GET_CONTENT); pickIntent.putExtra("crop", "true"); } else { pickIntent = new Intent(Intent.ACTION_OPEN_DOCUMENT); pickIntent.addCategory(Intent.CATEGORY_OPENABLE); pickIntent.setType("image/jpeg"); pickIntent.putExtra("crop", "true"); } Intent takePhotoIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); takePhotoIntent.putExtra(MediaStore.EXTRA_OUTPUT, getFileDirectory()); takePhotoIntent.putExtra("android.intent.extras.CAMERA_FACING", 1); String pickTitle = "Select or take a new Picture"; Intent chooserIntent = Intent.createChooser(pickIntent, […]

Firestore:查询android中数组中的所有元素

我有一个类似的数据结构 /Split // Collection {authid} // Document /SentIvitation //Collection {auto-id} //Documnet amount //array 0:10 1:10 2:10 Phonenumbers//array 0:987654321 1:123456789 2:234567890 我需要查询电话号码中的所有元素,我必须检查这些电话号码是否已经存在于另一个集合中。 我的数据结构的下一个路径是 /deyaUsers //Collection {authid}. //Documnet Name: “abc” Email: “abc@gmail.com” Phonenumber:987654321 在没有任何索引的情况下可以在firestore中使用吗?

Firestore – 在本地合并两个查询

由于Firestore中没有逻辑OR运算符,因此我尝试在本地合并2个单独的查询。 现在我想知道如何保持结果的正确顺序。 当我独立运行2个查询时,我无法特定地查询结果(至少不是我使用orderBy方法从Firestore获取结果的顺序)。 我的想法是将第二个查询放在第一个查询的onSuccessListener中。 这是一个表现明智的坏主意吗? public void loadNotes(View v) { collectionRef.whereLessThan(“priority”, 2) .orderBy(“priority”) .get() .addOnSuccessListener(new OnSuccessListener() { @Override public void onSuccess(QuerySnapshot queryDocumentSnapshots) { for (QueryDocumentSnapshot documentSnapshot : queryDocumentSnapshots) { Note note = documentSnapshot.toObject(Note.class); //adding the results to a List } collectionRef.whereGreaterThan(“priority”, 2) .orderBy(“priority”) .get() .addOnSuccessListener(new OnSuccessListener() { @Override public void onSuccess(QuerySnapshot queryDocumentSnapshots) { for (QueryDocumentSnapshot […]

PolyLine不在路上:它从一个点直接到另一个点

输出是我的地图包含多个点来点击用户的位置,他从那里通过polyLine没有在道路上显示,但显示从一个标记到另一个标记的直线我希望我的pollyline在道路转弯时穿过马路它也应该转向 dataholder = FirebaseDatabase.getInstance().getReference(“UserLocation”); Log.d(“onMapReady”, “iam here”); dataholder.addValueEventListener(new ValueEventListener() { @Override public void onDataChange(DataSnapshot dataSnapshot) { Log.d(“data”,String.valueOf(dataSnapshot.getValue())); System.out.println(dataSnapshot.getValue()); for (DataSnapshot a : dataSnapshot.getChildren()) { MapData mapData = a.getValue(MapData.class); arrayList.add(mapData); lati.add(arrayList.get(i).getLatituide()); longit.add(arrayList.get(i).getLongitude()); Log.d(“mapi”,”i am in loop”); mMap = googleMap; Double lat = Double.parseDouble(lati.get(i)); Double longi = Double.parseDouble(longit.get(i)); sydney = new LatLng(longi, lat); points.add(sydney); MarkerOptions mop = […]

不能在不同方法中定义的内部类中引用非final变量i

我有“不能在一个不同方法中定义的内部类中引用非最终变量”错误…我哪里出错了?…我刚开始学习android和java编程.. public class Tictac extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Button button[] = new Button[9]; button[0]= (Button) findViewById(R.id.button1); button[1] = (Button) findViewById(R.id.button2); button[2] = (Button) findViewById(R.id.button3); button[3] = (Button) findViewById(R.id.button4); button[4] = (Button) findViewById(R.id.button5); button[5] = (Button) findViewById(R.id.button6); button[6] = (Button) […]

如何从用户获取指纹输入并保存到android中的sqlite

我正在使用Android Marshmallow和Moto G4以及一个用于测试的设备。 我想创建一个应用程序,它将指纹输入并保存在本地数据库(sqlite)或数据库中,我的意思是我们可以采取哪种类型的输入并保存它?