
用户只能在编辑文本中输入一个数字.如果他在edtText1中输入值,我希望光标自动移动到edtText2,依此类推.用户可以编辑他/她已经输入的文本.我尝试了以下方式.
edtPasscode1.setOnKeyListener(new OnKeyListener() {
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
// TODO Auto-generated method stub
if (edtPasscode1.getText().length() == 1)
edtPasscode2.requestFocus();
return false;
}
});
edtPasscode2.setOnKeyListener(new OnKeyListener() {
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
// TODO Auto-generated method stub
if (edtPasscode2.getText().length() == 1)
edtPasscode3.requestFocus();
return false;
}
});
edtPasscode3.setOnKeyListener(new OnKeyListener() {
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
// TODO Auto-generated method stub
if (edtPasscode3.getText().length() == 1)
edtPasscode4.requestFocus();
return false; …Run Code Online (Sandbox Code Playgroud) 如果我设置android:layout_height="56dp",我可以在图形布局中看到工具栏.但是,当我设置如下,
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/purple"
android:gravity="center_vertical"
android:minHeight="?attr/actionBarSize"
app:layout_scrollFlags="scroll|enterAlways"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"> </android.support.v7.widget.Toolbar>
Run Code Online (Sandbox Code Playgroud)
工具栏未以图形布局显示.
Studio说它attr/actionBarSize被标记为私有.
我在用
compile 'com.android.support:appcompat-v7:23.0.0'
compile 'com.android.support:design:23.0.0'
Run Code Online (Sandbox Code Playgroud)
可能是什么问题?我该怎么办呢!是的,Studio已更新.
android android-appcompat android-toolbar android-design-library
如果你帮我用Retrofit调用一个简单的API GET方法会很好.我已将Gson和Retrofit jar文件添加到构建路径中.
这是interface:
public interface MyInterface {
@GET("/my_api/shop_list")
Response getMyThing(@Query("mid") String param1);
}
Run Code Online (Sandbox Code Playgroud)
我只得到结果(在log cat中)如果我在AsyncTask中调用以下内容,我会得到NetworkOrMainThreadException如何调用它?
@Override
protected Void doInBackground(Void... params) {
// TODO Auto-generated method stub
RestAdapter restAdapter = new RestAdapter.Builder()
.setEndpoint("http://IP:Port/")
.setLogLevel(RestAdapter.LogLevel.FULL).build();
MyInterface service = restAdapter
.create(MyInterface.class);
mResponse = service.getMyThing("455744");
return null;
}
Run Code Online (Sandbox Code Playgroud)
我刚从日食迁移到工作室.我跟着一个博客将项目从eclipse导出到了工作室.该应用程序在棒棒糖中运行良好,并在棒棒糖前设备中抛出以下错误.
仅在工作室中获取此错误.不是在日蚀.
FATAL EXCEPTION: main
java.lang.NoClassDefFoundError: android.support.v7.appcompat.R$layout
at android.support.v7.app.AppCompatDelegateImplV7.ensureSubDecor(AppCompatDelegateImplV7.java:324)
at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:246)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:106)
at com.hsp.inventory.SplashActivity.onCreate(SplashActivity.java:53)
at android.app.Activity.performCreate(Activity.java:5122)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1081)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2270)
//
......
//
Run Code Online (Sandbox Code Playgroud)
我的gradle文件
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
mavenCentral()
maven {
url "http://dl.bintray.com/journeyapps/maven"
}
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
}
}
allprojects {
repositories {
jcenter()
}
}
apply plugin: 'com.android.application'
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.android.gms:play-services:7.5.0'
compile 'com.android.support:design:22.2.0'
compile 'com.android.support:appcompat-v7:22.2.0' …Run Code Online (Sandbox Code Playgroud) 我有一个textview,如下所示:
txtByRegistering.setText("By Registering you agree to terms and condition and privacy policy");
Run Code Online (Sandbox Code Playgroud)
这只是一个大文本.所以,我用marquee水平滚动文本.工作正常.我的问题是,如何在单击选定的滚动文本时调用click事件.
说出来:
"Terms",我必须调用另一个新的Intent(具有术语的webview活动URL Link).由于"注册"和"术语"这个词是Web URL,我尝试过如下所示:
String mRegDesc = "By registering you agree to the " + "<a href=\""
+ Constant.URL + "/terms_and_conditions"
+ "\">Terms of Use</a> " + "and " + "<a href=\"" + Constant.URL
+ "/privacy" + "\">Privacy Policy</a> ";
txtByRegistering.setText(Html.fromHtml(mRegDesc));
txtByRegistering.setMovementMethod(LinkMovementMethod.getInstance());
txtByRegistering.setSelected(true);
txtByRegistering.setTypeface(mTyFaceOverLockReg, Typeface.BOLD);
Run Code Online (Sandbox Code Playgroud)
上面的代码工作正常,当我点击"条款"这个词时它会把我带到浏览器但是我希望转到新的活动.
大家中午好!
我Retrofit在我的应用程序中用于网络调用。该应用程序运行良好,速度非常快。感谢精彩的图书馆。但是,它仅适用于 wi-fi。如果我在 3G 网络中运行该应用程序,则会引发错误。stream was reset: PROTOCOL_ERROR, while using Retrofit in 3G network
我已将此 jar 文件导入到构建路径:

这是完整的堆栈跟踪:
11-17 16:01:54.017: D/Retrofit(3595): java.io.IOException: stream was reset: PROTOCOL_ERROR
11-17 16:01:54.017: D/Retrofit(3595): at com.squareup.okhttp.internal.spdy.SpdyStream.getResponseHeaders(SpdyStream.java:146)
11-17 16:01:54.017: D/Retrofit(3595): at com.squareup.okhttp.internal.http.SpdyTransport.readResponseHeaders(SpdyTransport.java:109)
11-17 16:01:54.017: D/Retrofit(3595): at com.squareup.okhttp.internal.http.HttpEngine.readResponse(HttpEngine.java:676)
11-17 16:01:54.017: D/Retrofit(3595): at com.squareup.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:426)
11-17 16:01:54.017: D/Retrofit(3595): at com.squareup.okhttp.internal.huc.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:371)
11-17 16:01:54.017: D/Retrofit(3595): at com.squareup.okhttp.internal.huc.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:466)
11-17 16:01:54.017: D/Retrofit(3595): at com.squareup.okhttp.internal.huc.DelegatingHttpsURLConnection.getResponseCode(DelegatingHttpsURLConnection.java:105)
11-17 16:01:54.017: D/Retrofit(3595): at com.squareup.okhttp.internal.huc.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:25)
11-17 16:01:54.017: D/Retrofit(3595): at retrofit.client.UrlConnectionClient.readResponse(UrlConnectionClient.java:73)
11-17 16:01:54.017: D/Retrofit(3595): at retrofit.client.UrlConnectionClient.execute(UrlConnectionClient.java:38)
11-17 …Run Code Online (Sandbox Code Playgroud) 在这里,我使用的是滑动面板库.您可以在以下屏幕中看到面板和列表视图.我想要做的是隐藏面板,如果我在面板外面点击(昏暗区域).而是点击上面布局中的列表视图.我怎样才能实现这一目标?

这是XML,
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res/com.voucher.point.activity"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<!-- sothree:dragView="@+id/dragView" -->
<com.sothree.slidinguppanel.SlidingUpPanelLayout
xmlns:sothree="http://schemas.android.com/apk/res-auto"
android:id="@+id/sliding_layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="bottom"
app:fadeColor="@color/transparent"
sothree:panelHeight="40dip"
sothree:paralaxOffset="200dp" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/white"
android:orientation="vertical" >
<ListView
android:id="@+id/offersList"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scrollbars="none"
android:visibility="gone" >
</ListView>
</LinearLayout>
<include
android:id="@+id/bottom_menu"
android:layout_width="fill_parent"
android:layout_height="270dip"
layout="@layout/side_menu" />
</com.sothree.slidinguppanel.SlidingUpPanelLayout>
Run Code Online (Sandbox Code Playgroud)
我可以这样做吗?

嗨,大家好,
我从API获得以下字段"Name"和"Skoda".会有x个这样的项目.根据设计,我应该在下图中显示它们.
所以,我决定以编程方式在名为"childLayout"的线性布局中创建两个textview,如下所示.
-- RelativeLayout
-- Linear Layout
-- TextView Textview --
-- Linear Layout
-- Linear Layout
-- TextView Textview --
-- Linear Layout
-- Linear Layout
-- TextView Textview --
-- Linear Layout
--RelativeLayout
Run Code Online (Sandbox Code Playgroud)
但我没有得到理想的输出.请帮我解决这个问题.
这是代码:
TextView mType;
TextView mValue;
for (int i = 0; i < getDetailedDescAL.size(); i++) {
LinearLayout childLayout = new LinearLayout(
DetailedCategories.this);
LinearLayout.LayoutParams linearParams = new LinearLayout.LayoutParams(
LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT);
childLayout.setLayoutParams(linearParams);
mType = new TextView(DetailedCategories.this);
mValue = new TextView(DetailedCategories.this);
mType.setLayoutParams(new TableLayout.LayoutParams(
LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT, 1f));
mValue.setLayoutParams(new …Run Code Online (Sandbox Code Playgroud)