我有一个Application类来保持我的应用程序的全局状态.但是我无法在Manifest文件中注册它?知道怎么做吗?
Android View.setPadding(int left, int top, int right, int bottom)只接受px中的值,但我想在dp中设置填充.它有什么办法吗?
我下载图像并使用动态设置为屏幕背景Imageview.我试过ScaleType,缩放图像.
如果图像高度大于宽度那么ScaleTypes fitStart,fitEnd并且fitCenter不起作用.Android缩小照片并根据高度调整它,但我看到一些额外的空白空间作为宽度的一部分.
我想根据宽度缩小照片,使其适合宽度,我不在乎是否有一些额外的空白空间作为高度的一部分,或者如果高度太长,如果它超出视图就没关系(如果可能的话?).
ScaleType.XY缩放照片并适应所有内容ImageView并且不关心图像高度/重量比.
<ImageView
android:id="@+id/background"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:adjustViewBounds="true"
android:scaleType="fitStart"
/>
Run Code Online (Sandbox Code Playgroud) 我必须在我的Android应用程序中解析一些复杂的xml文件.像TouchXMl for iPhone那样有没有好的库?
我使用支持库(23.0.1)制作无边框平面按钮.它在Lollipop上正常工作.但是在Lollipop之前我按下按钮它的颜色变成了colorButtonNormal颜色,就像它是一个普通的按钮.
我不这么认为这是一种正常的行为,聚焦的颜色应该像Lollipop一样灰.
这是Lollipop和Pre-lollipop的截图.
Lollipop上的第一个正常行为:正常状态下的无边框按钮和棒棒糖上的聚焦状态
在Pre-Lollipop上不正常的行为(Desire颜色像上面的灰色,但不是):正常状态下的无边框按钮和前棒棒糖上的聚焦状态

主题
<style name="AppTheme.Base" parent="Theme.AppCompat.Light.NoActionBar">
//other stuff
<item name="colorButtonNormal">@color/orangeColor</item>
<item name="buttonBarButtonStyle">@style/BorderlessButtonStyle</item>
</style>
<style name="BorderlessButtonStyle" parent="Widget.AppCompat.Button.Borderless">
<item name="android:textColor">@color/blueTextColor</item>
</style>
Run Code Online (Sandbox Code Playgroud)
现在按钮布局:
<Button
android:id="@+id/btnForgotPassword"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/forgot_your_password"
style="?attr/buttonBarButtonStyle"
/>
Run Code Online (Sandbox Code Playgroud)
任何方式来使用AppCompat主题和样式来编写它而无需单独的Drawables.
android android-layout android-support-library material-design android-design-library
我正在使用Twitter4J库进行OAuth身份验证,但即使在它打开Twitter登录页面之前,我也会收到"身份验证挑战是空的例外".
这是代码.
Twitter twitter = new TwitterFactory().getInstance();
try
{
twitter.setOAuthConsumer(Startup.TWITTER_KEY, Startup.TWITTER_SECRET);
String callbackURL = "twitter-client:///";
RequestToken rToken = twitter.getOAuthRequestToken(callbackURL);
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(rToken.getAuthenticationURL())));
}
catch(IllegalStateException e)
{
// access token is already available, or consumer key/secret is not set.
if(!twitter.getAuthorization().isEnabled()){
System.out.println("OAuth consumer key/secret is not set.");
System.exit(-1);
}
}
catch(Exception e)
{
Toast.makeText(Home.this, "Network Host not responding: "+e.getMessage(),Toast.LENGTH_SHORT).show(); //This exception.
}
Run Code Online (Sandbox Code Playgroud)
例外:
E/Home(4393):接收的认证质询为空E/Home(4393):接收的认证质询为null相关的讨论可以在因特网上:E/Home(4393):http: //www.google.co.jp/search?q = 6c607809 或E/Home(4393):http: //www.google.co.jp/search ?q = 0f1d8134 E/Home(4393):TwitterException {exceptionCode = [6c607809-0f1d8134 cab4c0ac-d492a113] ,statusCode …
以前的人有相同的错误消息,但解决方案一直是删除或修改一些导入"android.R".我没有这么重要,所以我真的迷失了
我正在尝试运行示例Android谷歌地图程序.
我正在学习本教程.http://www.vogella.com/articles/AndroidGoogleMaps/article.html
但是,当我粘贴代码时,eclipse会给我这个错误:"activity_main无法解析或者不是字段"
这段代码中的MainActivity会发生这种情况
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;}
Run Code Online (Sandbox Code Playgroud)
具体错误发生在"R.menu.activity_main"部分.
这是我的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"
tools:context=".MainActivity" >
<fragment
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.MapFragment" />
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
这是我的完整MainActivity.java类
package com.example.mapssample;
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapFragment;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;
public class MainActivity extends Activity {
static final LatLng HAMBURG = new LatLng(53.558, 9.927);
static final LatLng KIEL = new LatLng(53.551, 9.993);
private GoogleMap map;
@Override …Run Code Online (Sandbox Code Playgroud) 我能够流动音频并且没有任何问题地停止它,但是当我尝试在停止后再次启动它时,它不会启动并且我得到一个IllegalState异常.
这是我正在做的事情:
开始玩
mediaPlayer.setDataSource(PATH);
mediaPlayer.prepare();
mediaPlayer.start();
Run Code Online (Sandbox Code Playgroud)
别玩了
mediaPlayer.stop
Run Code Online (Sandbox Code Playgroud)
现在,如果我想再次开始播放相同的媒体,我该怎么做?
*PATH是连续运行的无线电台的URL.
我正在使用google-api-ruby-client来处理Google Calendar API v3.
我面临的唯一问题是两次更新事件.
之前已经讨论过(Google Calendar api v3重新更新问题),但没有ruby客户端,也没有答案.
当我添加一个新事件时,我会得到一个ID和一个ETAG.我使用ID来更新事件,我得到一个新的ETAG.现在如果我尝试更新第二次,它不会更新并发送400错误消息"无效值".
我必须在第二次更新时发送最新的ETAG但我不确定如何在使用google-api-ruby-client时发送它.
这是代码:
event = {
'summary' => "Summary",
'location' => "Location",
'description' => "Description",
'start' => {
'dateTime' => @entry.from_date
},
'end' => {
'dateTime' => @entry.to_date
}
}
result = client.execute(:api_method => service.events.update,
:parameters => {'calendarId' => @entry.calendar.gid, 'eventId'=>@entry.gid},
:body => JSON.dump(event),
:headers => {'Content-Type' => 'application/json'})
Run Code Online (Sandbox Code Playgroud) 我正在尝试从 Android 手机上的麦克风记录噪音分贝。我可以获得振幅值并寻找将其转换为分贝的公式。
我使用 MediaRecorder 的以下功能来获取幅度。
mediaRecorder.getMaxAmplitude() ;
在另一个问题中,我找到了以下公式。
power_db = 20 * log10(amp / amp_ref);
amp是振幅但不确定是什么amp_ref。
有谁知道正确的公式吗?
I would like to add a custom button to SearchView widget.
Going through source code of search_view layout file I found out that it has a LinearLayout (submit_area) that contains submit button and voice button.
So I added a dynamic button to submit_area. But it doesn't show my dynamically added button because if either submit button or voice button is not enabled then submit_area is invisible. So it doesn't matter if I add anything dynamically.
SearchView searchView = …Run Code Online (Sandbox Code Playgroud) android android-custom-view android-button android-actionbar searchview
我想用递归级别3来检索数据.问题是它添加了所有8个链接模型,但我只需要来自三个数据模型的数据.有没有办法忽略某些模型或特别问一些模型,但不是全部.像useModel('Model1','Model2')?
android ×10
php ×2
amplitude ×1
android-xml ×1
audio ×1
base64 ×1
binary ×1
cakephp ×1
decibel ×1
google-maps ×1
java ×1
media-player ×1
microphone ×1
oauth ×1
ruby ×1
searchview ×1
twitter ×1
twitter4j ×1
xml ×1