在网上我看到的例子如edittext.getText().toString()
.我没有看到任何空检查.在文档中,我没有看到任何声明,它永远不会为空.
不过,观察结果表明了什么; 这是否会返回null?
我WebView
在webview中加载了所有链接 - 但是当我选择一个电子邮件链接时,它会尝试在webview中加载它而不是在手机上启动电子邮件应用程序.我该如何解决?链接是mailto://someone@somewhere.com
这是我的代码 - 它WebView
本身正常工作,所有内容都在webview中加载,包括mailto:等.需要mailto链接加载到其他地方
package com.apps.jerdog.crcc;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.KeyEvent;
import android.webkit.WebView;
import android.webkit.WebViewClient;
@SuppressWarnings("unused")
public class mainActivity extends Activity {
/** Called when the activity is first created. */
/**@Override */
WebView webview;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
webview = (WebView) findViewById(R.id.webview);
webview.getSettings().setJavaScriptEnabled(true);
webview.getSettings().setSupportZoom(true);
webview.getSettings().setBuiltInZoomControls(true);
webview.setWebViewClient(new WebViewClient());
webview.loadUrl("http://www.cedarridge.cc");
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if ((keyCode == KeyEvent.KEYCODE_BACK) && webview.canGoBack()) {
webview.goBack(); …
Run Code Online (Sandbox Code Playgroud) 我需要调整此部件尺寸以完全显示.我怎样才能做到这一点?
我的适配器:
String[] navigations = getResources().getStringArray(R.array.actionBar);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(
getBaseContext(), R.layout.custom_spinner_title_bar,
android.R.id.text1, navigations);
adapter.setDropDownViewResource(R.layout.custom_spinner_title_bar);
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
actionBar.setListNavigationCallbacks(adapter, navigationListener);
Run Code Online (Sandbox Code Playgroud)
custom_spinner_title_bar.xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/RelativeLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="fill_horizontal"
android:orientation="vertical" >
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/text1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="5dip"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#FFFFFF" />
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud) 我已经将ADH8066(Sparkfun)GSM模块连接到我的Arduino Uno,我正试图在Arduino和GSM模块之间进行正确的串行连接.当我直接(通过USB或只是TTL线)连接它时它工作正常,但是当通过Arduino控制时却没有.一些文本将正确输出,其余文本将出现乱码,几乎就像波特率错误一样,但我只是使用与从PC连接时相同的波特率(115200).
这是我正在使用的Arduino代码:
#include <SoftwareSerial.h>
#define rxPin 7
#define txPin 8
SoftwareSerial mySerial = SoftwareSerial(rxPin, txPin);
// EN: String buffer for the GPRS shield message
String SmsStorePos = String("");
String msg = String("");
String snTmp = String("");
String snFull = String("");
// EN: Set to 1 when the next GPRS shield message will contains the SMS message
int SmsContentFlag = 0;
// EN: Pin of the LED to turn ON and OFF depending on the received message
int ledPin = …
Run Code Online (Sandbox Code Playgroud) 我想实现类似于谷歌的游戏商店的弹出菜单,如下所示.
所以基本上从我的理解,我将需要一个活动和布局为这个活动定义在其中的listview.我需要创建我的自定义适配器.另外,我需要创建一个列表布局,其中包含信息和一个视图(带有3个点),用作启动弹出菜单的按钮?我在这里看到的问题是,我如何仅为此视图创建一个侦听器,以及如何在列表视图中引用该特定列表项的值.
我没有任何代码可用,因为我还没有开始任何与此相关的事情.我目前正在理论上获取信息,但如果需要,我将创建一个示例代码.
谢谢.
我有一个关于在Android中旋转菜单的问题.我想让动画菜单像枪筒一样移动.
其中1-6是ImageButtons,按钮顺时针或反向旋转取决于您触摸屏幕的方式.我知道如何放置ImageButtons等但我从来没有制作动画菜单,总是静态的.如果你能帮助我,我将非常感激.
我在一个非常基本的Handler教程中遇到了这段代码.代码工作正常,但我不明白为什么我必须使用Handler progressDialog.dismiss()
??? 我删除了处理程序部分并放置 progressDialog.dismiss()
在run()
方法中,它工作正常.那么为什么使用Handler ???
import android.app.Activity;
import android.app.ProgressDialog;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;
public class HandlerThread extends Activity{
private Button start;
private ProgressDialog progressDialog;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
start = (Button) findViewById(R.id.Button01);
start.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
fetchData();
}
});
}
protected void fetchData() …
Run Code Online (Sandbox Code Playgroud) 所以我有一个带有LinearLayout的ScrollView.似乎当我试图滚动到我的线性布局的底部时,底部〜5倾角被切断(即底部边距)我认为它可能与我的线性布局的5dip边缘有关?
这是activity_create_account.xml
:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:background="@drawable/grey"
android:orientation="vertical"
android:padding="0dp"
tools:context=".Login" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:weightSum="100"
android:orientation="vertical">
<!-- BEGIN HEADER -->
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:background="@drawable/titlebar"
android:orientation="horizontal"
android:padding="8dip" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="0dp"
android:text="create account"
android:textColor="#FFFFFF"
android:textSize="32sp"
android:textStyle="bold"
android:typeface="sans" />
</LinearLayout>
<!-- END HEADER -->
<!-- BEGIN BODY -->
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="top"
android:orientation="vertical">
<LinearLayout
android:id="@+id/innerLinearLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="10dip"
android:background="@drawable/rounded_white"
android:orientation="vertical"
android:padding="5dip" >
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="textEmailAddress"
android:ems="10"
android:id="@+id/etCreateEmail"
android:hint="Email"
android:layout_weight="1"
android:paddingTop="8dip"
android:paddingBottom="8dip"
android:paddingRight="8dip"
android:paddingLeft="8dip"
android:layout_marginBottom="4dip" …
Run Code Online (Sandbox Code Playgroud) 在我的应用程序中,我有两种类型的编辑域.其中一个行为类似于单行编辑域,另一个行为类似于多行编辑域(editarea).在这个屏幕中,我有一个标题,一个编辑区和一个编辑区.当我输入一些文本时editfield
,它会剪切文本和光标.但是,当我输入一些editarea
包含尾部字符(y,g,q,p)editarea
的文本时,高度正在变化并且editfield
正常.如果我不输入尾部字符,stuation不会改变.
这是我的editarea课程:
public class EditAreaField extends HorizontalFieldManager{
private net.rim.device.api.ui.component.EditField editArea;
public EditAreaField (){
// some code;
editArea.setPadding(25, 10, 0, 10);
}
public int getPreferredHeight() {
int height = Math.max(editArea.getHeight(), textFont.getHeight());
return height + editArea.getPaddingTop();
}
}
Run Code Online (Sandbox Code Playgroud)
label1 - > editfield
label2 - > editarea
屏幕旋转后,其中一个视图对象的高度发生变化,我想知道像素中的高度值.
该onConfigurationChanged
方法可能在视图完成旋转之前调用.因此,如果我在此方法中测量视图大小,则大小仍然是之前的旋转值.
问题是如何在旋转完成后获取视图大小值而不重建Activity.
android ×8
java ×2
animated ×1
arduino ×1
blackberry ×1
menu ×1
rotation ×1
serial-port ×1
spinner ×1
titlebar ×1