Questions tagged «android»

Android是Google的移动操作系统,用于对数字设备(智能手机,平板电脑,汽车,电视,Wear,Glass和IoT)进行编程或开发。对于与Android相关的主题,请使用特定于Android的标签,例如android-intent,android-activity,android-adapter等。对于与开发或编程无关但与Android框架相关的问题,请使用以下链接:https:// android.stackexchange.com。

17
CardView在Android L中未显示阴影
我在Listview中的Cardview在Android L(Nexus 5)中没有显示阴影。同样,圆形边缘也没有正确显示。这是Listview的Adapter View的代码: <?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" xmlns:card_view="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res/com.example.myapp" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" > <android.support.v7.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto" android:id="@+id/card_view" android:layout_width="match_parent" android:layout_height="wrap_content" app:cardBackgroundColor="@android:color/white" android:foreground="?android:attr/selectableItemBackground" app:cardCornerRadius="4dp" app:cardElevation="4dp" > <RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingTop="@dimen/activity_vertical_margin" > <TextView android:id="@+id/tvName" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentTop="true" android:layout_marginTop="@dimen/padding_small" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:textAppearance="?android:attr/textAppearanceLarge" /> <ImageView android:id="@+id/ivPicture" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below="@+id/tvName" android:layout_centerHorizontal="true" android:scaleType="fitCenter" /> <TextView …


5
Android ListView标头
我有ListView上面有某种事件。事件是按天排序的,我希望每天都有带有日期的标头,然后事件在下面侦听。 这是我填充该列表的方式: ArrayList<TwoText> crs = new ArrayList<TwoText>(); crs.add(new TwoText("This will be header", event.getDate())); for (Event event : events) { crs.add(new TwoText(event.getStartString() + "-" + event.getEndString(), event.getSubject())); } arrayAdapter = new TwoTextArrayAdapter(this, R.layout.my_list_item, crs); lv1.setAdapter(arrayAdapter); 这是我的类TwoText的外观: public class TwoText { public String classID; public String state; public TwoText(String classID, String state) …


13
WebView和HTML5 <视频>
我正在拼凑一个cheapo应用程序,该应用程序除其他外可以“构架”我们的某些网站...使用,非常简单WebViewClient。直到我看了视频。 视频是作为HTML5 元素完成的,在Chrome,iPhone上这些视频可以正常工作,而且现在我们已解决了编码问题,Android在本机浏览器中效果很好。 现在的问题是:WebView不喜欢它。完全没有 我可以单击海报图像,但没有任何反应。 谷歌搜索,我发现这很接近,但似乎是基于“链接”(如href ...),而不是视频元素。(onDownloadListener似乎未在视频元素上被调用...) 我还看到了有关覆盖onShowCustomView的引用,但似乎未在视频元素上调用……shouldOverrideUrlLoading也没有。 我宁愿不要进入“从服务器中提取xml,在应用程序中重新格式化它” ..通过在服务器上保留故事的布局,我可以更好地控制内容,而不必强迫人们不断更新应用程序。因此,如果我可以说服WebView处理本机浏览器之类的标签,那将是最好的。 我显然缺少明显的东西。但是我不知道是什么。

12
Android 5.0-将页眉/页脚添加到RecyclerView
我花了一点时间试图找出一种将标头添加到的方法RecyclerView,但未成功。 这是我到目前为止所得到的: @Override protected void onCreate(Bundle savedInstanceState) { ... layouManager = new LinearLayoutManager(getActivity()); recyclerView.setLayoutManager(layouManager); LayoutInflater inflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE); headerPlaceHolder = inflater.inflate(R.layout.view_header_holder_medium, null, false); layouManager.addView(headerPlaceHolder, 0); ... } 在LayoutManager似乎是处理的配置对象RecyclerView的项目。由于找不到任何addHeaderView(View view)方法,因此决定使用LayoutManager的addView(View view, int position)方法,并将标头视图添加到第一个位置以用作标头。 Aaand这就是事情变得更糟的地方: java.lang.NullPointerException: Attempt to read from field 'android.support.v7.widget.RecyclerView$ViewHolder android.support.v7.widget.RecyclerView$LayoutParams.mViewHolder' on a null object reference at android.support.v7.widget.RecyclerView.getChildViewHolderInt(RecyclerView.java:2497) at …

3
ASP.NET Web API身份验证
我希望在使用ASP.NET Web API时从客户端应用程序对用户进行身份验证。我已经观看了网站上的所有视频,还阅读了该论坛帖子。 [Authorize]正确放置属性将返回401 Unauthorized状态。但是,我需要知道如何允许用户登录到API。 我想从Android应用程序向API提供用户凭据,让用户登录,然后对所有后续API调用进行预身份验证。

1
使用Google Guava库进行Android开发是一个好主意吗?
我参与了Android应用程序的开发,该应用程序是Web服务的“相当”厚的移动客户端。它与服务器进行大量通信,但也具有许多内部逻辑。因此,我决定使用Google Guava库的某些功能来简化开发过程。这是我非常感兴趣的功能列表:不可变集合,基本utils,集合扩展,函数式编程糖和习惯用法(common.collect和common.base),基元实用程序(common.primitives),哈希实用程序(common.hash),并发实用程序(futures和AsyncFunction)。我不想在Android中使用的东西:(common.cache请参见下面的问题),common.eventbus(为此我们有更好的Android特定库,例如Otto),common.io(我们可以使用okio 现在适用于Android)。 我读到,使用Guava for Android会大大减慢编译过程,并降低整个运行时性能:Android上的Guava Cache的性能 较差 (在这种情况下,这是合理的,不需要为Android使用Guava的缓存),并且 添加了Google番石榴到Android项目-大大减慢了构建速度 那么,是不是有效的在Android项目使用番石榴库或该库的设计使用仅用于服务器端开发,我应该用标准的解决方案去?任何解释将不胜感激。
122 java  android  guava 


11
Android-创建JSON数组和JSON对象
如何在Android中以这种格式创建JSON:由于我将传递的API将解析JsonArray,然后解析该对象。还是只传递一个json对象就可以了吗?因为我只需要在每个服务调用中插入1个事务即可。 { "student": [ { "id": 1, "name": "John Doe", "year": "1st", "curriculum": "Arts", "birthday": 3/3/1995 }, { "id": 2, "name": "Michael West", "year": "2nd", "curriculum": "Economic", "birthday": 4/4/1994 } ] } 我所知道的只是JSONObject。像这个。 JSONObject obj = new JSONObject(); try { obj.put("id", "3"); obj.put("name", "NAME OF STUDENT"); obj.put("year", "3rd"); obj.put("curriculum", "Arts"); …
122 android  json  arrays 

6
处理菜单项单击事件-Android
我想创建一个意图,一旦单击菜单项,便会启动新活动,但是我不确定如何执行此操作。我一直在阅读android文档,但是我的实现是不正确的..一些正确方向的指导会有所帮助。我在下面列出了我的代码并注释了我的问题领域,我认为我在调用错误的方法。 package com.jbsoft.SimpleFlashlight; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.*; import android.view.MenuItem.OnMenuItemClickListener; import android.widget.Button; import android.widget.Toast; public class SimpleFlashLightActivity extends Activity { Button GreenButton; // Declare instances of buttons to use later Button BlueButton; private static final int OK_MENU_ITEM = Menu.FIRST; /** Called when the activity is first created. …



16
应用内结算测试:android.test.purchased已拥有
我目前正在为未来的应用测试应用内结算,并且在第一次成功“购买”测试项目“ android.test.purchased”之后,每次尝试再次购买时,我都会收到响应代码7,这表示我已经拥有此商品。 12-15 23:02:14.149:E / IabHelper(19829):应用内结算错误:无法购买商品,错误响应:7:商品已拥有 据我了解,这种购买应该总是可能的,对吧?以便开发人员可以测试他/她的应用程序? 如果没有,如何将其状态“重置”为不拥有?我正在使用Google应用内结算示例中的util软件包。


By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.