假设我声明了一个变量:
String a = "test";
Run Code Online (Sandbox Code Playgroud)
我想知道它是什么类型,即输出应该是java.lang.String我该怎么做?
我想在某个活动开始时调用服务.那么,这是Service类:
public class UpdaterServiceManager extends Service {
private final int UPDATE_INTERVAL = 60 * 1000;
private Timer timer = new Timer();
private static final int NOTIFICATION_EX = 1;
private NotificationManager notificationManager;
public UpdaterServiceManager() {}
@Override
public IBinder onBind(Intent intent) {
// TODO Auto-generated method stub
return null;
}
@Override
public void onCreate() {
// Code to execute when the service is first created
}
@Override
public void onDestroy() {
if (timer != null) {
timer.cancel();
}
}
@Override
public int …Run Code Online (Sandbox Code Playgroud) 所以我有一个ImageView设置
android:maxHeight="100px"
android:maxWidth="250px"
android:minHeight="100px"
android:minWidth="250px"
android:scaleType="centerInside"
Run Code Online (Sandbox Code Playgroud)
此图像视图用于显示从图库或相机获取的图片.在这两种情况下,图像都不会调整大小以适应图像视图,它只是根据需要拉伸其空间.
知道怎么让它留在那些界限内吗?
<?xml version="1.0" encoding="utf-8"?>
Run Code Online (Sandbox Code Playgroud)
<EditText
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:id="@+id/txtDescription"
android:layout_below="@+id/txtSubject"
android:inputType="textMultiLine"
android:height="80px"
android:hint="@string/description"></EditText>
<EditText
android:layout_height="wrap_content"
android:layout_below="@+id/txtDescription"
android:layout_width="fill_parent"
android:id="@+id/txtMorada"
android:hint="@string/address" />
<ImageButton
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_below="@+id/txtMorada"
android:id="@+id/btGPS"
android:layout_alignParentLeft="true"
android:src="@drawable/ic_menu_compass"></ImageButton>
<ImageView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_below="@+id/btGPS"
android:layout_marginTop="25px"
android:id="@+id/imgPoint"
android:src="@drawable/google_logo_small"
android:maxHeight="100px"
android:maxWidth="250px"
android:minHeight="100px"
android:minWidth="250px"
android:scaleType="centerInside"></ImageView>
<ImageButton
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_toRightOf="@+id/imgPoint"
android:id="@+id/btGallery"
android:layout_below="@+id/btCamera"
android:src="@drawable/ic_menu_gallery"
android:layout_alignParentRight="true"></ImageButton>
<Button
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_marginTop="10px"
android:id="@+id/btSubmit"
android:layout_below="@+id/btGallery"
android:text="@string/submit"></Button>
<ImageButton
android:layout_height="wrap_content"
android:id="@+id/btMap"
android:layout_below="@+id/txtMorada"
android:layout_width="wrap_content"
android:layout_alignParentRight="true"
android:src="@drawable/ic_menu_mapmode"></ImageButton>
<TextView
android:layout_below="@+id/txtMorada"
android:layout_width="wrap_content"
android:layout_toLeftOf="@+id/btMap"
android:layout_height="wrap_content"
android:id="@+id/lblNewPointLatitude"
android:text="Latitude"></TextView>
<TextView
android:layout_width="wrap_content"
android:layout_toLeftOf="@+id/btMap"
android:layout_height="wrap_content"
android:id="@+id/lblNewPointLongitude"
android:layout_below="@+id/lblNewPointLatitude" …Run Code Online (Sandbox Code Playgroud) 我正在使用symfony2框架,我想使用PHP的DateTime类(PHP版本是5.3).
声明在这里:
namespace SDCU\GeneralBundle\Entity;
class Country
{
public function __construct(){
$this->insertedAt = new DateTime();
}
}
Run Code Online (Sandbox Code Playgroud)
但是,在执行此构造函数时,我收到一条错误消息,指出没有"SDCU\GeneralBundle\Entity\DateTime"类.我一直在寻找DateTime的命名空间,但没有成功......任何想法?
我有一个活动CoordinatorLayout,AppBarLayout,CollapsingToolbarLayout和Toolbar.所以,基本上,滚动时会崩溃的视图RecyclerView.
我需要做的是当展开的布局视图由于折叠而隐藏时显示自定义视图.
这是我的布局:
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="192dp"
android:fitsSystemWindows="true"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:contentScrim="#2196F3"
app:expandedTitleMarginBottom="32dp"
app:expandedTitleMarginEnd="64dp"
app:expandedTitleMarginStart="48dp"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<include
android:id="@+id/header"
layout="@layout/header_big_first_screen"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:scaleType="centerCrop"
app:layout_collapseMode="parallax"/>
<android.support.v7.widget.CollapsingToolbarLayout
android:id="@+id/anim_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Hello!"/>
</android.support.v7.widget.CollapsingToolbarLayout>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v7.widget.RecyclerView
android:id="@+id/categories_recyclerview"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
</android.support.design.widget.CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud)
最后,当工具栏展开时,将显示加载了元素的视图.当它折叠时它没有.当它消失时,应显示TextView内部Toolbar.目前它一直显示.
我一直在查看在CollapsingToolbarLayout更改大小时添加侦听器的事件,以便我可以检查它是否小于值并显示该视图.
这可能有点难以解释,但我相信我已经清楚了.我一直在谷歌搜索,找不到任何人试图做同样的事情.
android android-toolbar android-coordinatorlayout android-collapsingtoolbarlayout
我正在尝试制作这样的东西:我有一个mapactivity,当用户点击地图时,它会显示该位置的坐标.我已经覆盖了onclick方法,但它甚至没有被调用.任何的想法?
public class MapPoint extends MapActivity implements OnClickListener {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.mappoints);
MapView map = (MapView)findViewById(R.id.mapview);
map.setOnClickListener(this);
map.setBuiltInZoomControls(true);
map.getController().setZoom(18);
map.getController().setCenter(new GeoPoint(39735007, -8827330));
}
@Override
protected boolean isRouteDisplayed() {
// TODO Auto-generated method stub
return false;
}
public void onClick(View arg0) {
Toast.makeText(this, "text", Toast.LENGTH_SHORT);
}
Run Code Online (Sandbox Code Playgroud)
}
我正在尝试将来自android的数据(使用其SDK中的API)发送到使用Windows上的Bluecove的PC,这是最后一个服务器.
我可以让android连接到服务器但是当我写入套接字的输出流时,服务器上没有任何反应.我有onPut方法覆盖但它从未被调用.
代码如下,如果有人可以帮助我,我将非常感激:
Android的
public class BluetoothWorker {
private static UUID generalUuid = UUID.fromString("00001101-0000-1000-8000-00805F9B34FB");
private static BluetoothSocket socket;
private static BluetoothSocket getBluetoothSocket(){
BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
mBluetoothAdapter.cancelDiscovery();
Set<BluetoothDevice> pairedDevices = mBluetoothAdapter.getBondedDevices();
// If there are paired devices
if (pairedDevices.size() > 0) {
// Loop through paired devices
for (BluetoothDevice device : pairedDevices) {
// Add the name and address to an array adapter to show in a ListView
if(device.getName().equalsIgnoreCase(("MIGUEL-PC"))){
try {
return device.createRfcommSocketToServiceRecord(generalUuid);
} catch (IOException e) {
return null; …Run Code Online (Sandbox Code Playgroud) 我想选择执行JUnit测试的顺序.我有4个类,里面有几个测试方法,我的目标是执行,例如,类A的方法Y,然后是类B的方法X,最后是类A的方法Z.
你能帮帮忙吗?
我正在创建一个为移动设备生成和提供网页的Web应用程序.例如,用户配置要显示的数据并使用速度模板生成最终的HTML/CSS/JS文件.当配置模板和要包括的信息时,客户端连接到服务器以显示生成的页面.
但是,我现在正在为此创建预览屏幕.所以,让我们说,我想看看它会是什么样子,比方说,Nexus 5.
我的目标是在Chrome上创建类似谷歌的东西 - 移动设备模拟.问题是我无法理解他们如何能够进行这种模拟.
确实,必须缩小内容才能显示所有内容.这很容易理解,好像屏幕不够大,我们需要使它适合.
所以,我知道设备的屏幕对角线尺寸,它的分辨率和PPI(点英寸).我需要知道的是如何为我的网站进行适当的测量以模拟设备.当我转到Chrome仿真工具时,我发现Nexus 5显示为:
我知道他们如何计算像素宽高比:它是设备的PPI除以160(基本PPI).因此,445/160 = ~3(445是Nexus 5的像素密度).这就是他们如何达到360 x 640:他们将分辨率除以像素长宽比(3).
在我的网站上,我有一个iframe并将生成的页面加载到其中.然后我知道我必须应用缩放级别.这就是问题所在.我真的不知道缩放的值应该是多少.
其中一个尝试是
1 /((屏幕对角线)/像素宽高比)= 1 /(4.95/3)= 0.6060(60)
应用此缩放使其看起来很好.如果我使用亚马逊Kindle HDX采用相同的方法,它也可以.
但是,如果我使用LG L70,我会得到以下信息:
1 /(4.5/1.25)= 0.27777777 ......
问题是,与Nexus 5相比,应用这种缩放的东西会更小(因为缩小了很多),而在Chrome仿真模式下,它们看起来非常相似.
如果有任何信息可以帮助解决这个难题,请告诉我.
我有一个函数负责在应用程序中发出HTTP请求.基本上,它设置所有必需的标题,超时等等...然后,当请求完成时,我运行2个函数(由开发人员提供):whenSuccess/ whenError(取决于调用的结果)和whenComplete(无论通话结果如何).我希望最后一个能够接收whenSuccess函数的结果.
我将doRequest函数声明为
private func doRequest<S>(whenSuccess: (_ json: JSON?)->(S?),
whenError: (_ description: String)->(),
whenComplete: Optional<(S?)->()>) {
// yada yada yada
}
Run Code Online (Sandbox Code Playgroud)
因此,开发人员提供了一个获取JSON并返回泛型的函数.如果whenError调用,whenComplete则使用nilas参数调用.
我正在调用它
doRequest<Int>(whenSuccess: { (json) -> (Int?) in //Cannot specialize a non-generic definition
return 5
}, whenError: { (error) in
}) { (success) in
}
Run Code Online (Sandbox Code Playgroud)
我收到错误评论:
无法专门化非泛型定义
知道是否可以这样做以及如何做?
android ×5
java ×2
android-collapsingtoolbarlayout ×1
bluecove ×1
bluetooth ×1
connection ×1
coordinates ×1
datetime ×1
emulation ×1
generics ×1
html ×1
imageview ×1
junit ×1
map ×1
namespaces ×1
netbeans ×1
php ×1
resize ×1
screen ×1
service ×1
stretch ×1
swift ×1
swift3 ×1
tap ×1
testing ×1
touch ×1
types ×1
variables ×1
zoom ×1