你好可以投一个名单吗?
我有一个抽象类,它有一个方法,它采用某种List <>,在for循环中迭代它,获取该列表中的每个对象,并调用子类实现的insertItem抽象方法,基本上拉出正确的项目中的数据,然后最终将它们插入数据库表.
这是超类方法:
protected void insertAllItemsToDb(List<Object> items, String table) {
// open db and table
database().beginTransaction();
// clear all data from table
clearTable(table);
// call a insert statement to insert each column from an item
for (Object object : items) {
insertItem(object, table);
}
// close db
database().endTransaction();
database().close();
}
Run Code Online (Sandbox Code Playgroud)
在子类中,这是一个覆盖方法:我能够在这里强制转换对象.
@Override
protected void insertItem(Object object, String table) {
CalendarEventItem item = (CalendarEventItem) object;
eventItemValue = new ContentValues();
eventItemValue.put(LABEL_EVENTS_TITLE, item.getEventTitle());
eventItemValue.put(LABEL_EVENTS_LOCATION, item.getEventLocation());
eventItemValue.put(LABEL_EVENTS_DATE, item.getEventStartTime()
.getDate());
eventItemValue.put(LABEL_EVENTS_TIME, item.getEventStartTime()
.getTime());
eventItemValue.put(LABEL_EVENTS_TIMEZONE, …Run Code Online (Sandbox Code Playgroud) 我想知道他们是否更好地做这样的事情:
SELECT *
FROM tableA
WHERE colour='red' OR colour='greed' OR colour='blue' OR colour='yellow'
Run Code Online (Sandbox Code Playgroud)
他们是这样的:
SELECT *
FROM tableA
WHERE colour='red''greed''yellow'
Run Code Online (Sandbox Code Playgroud)
提前喝彩
我正在使用phonegap创建一个显示html5网页的原生Android应用程序,问题是在模拟器上,该应用程序产生一个应用程序错误说:
"the connection to the server was unsuccesfull(file://android_assets/www/index.html)"
Run Code Online (Sandbox Code Playgroud)
相同的应用程序在我的HTC One X上发布正常,所以我不认为这是我的代码的问题.
这是我的android代码
public class MainScreen extends DroidGap
{
private Caller caller;
private static final String Wrapper = "Wrapper";
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
super.init();
caller = new Caller(this,appView);
appView.addJavascriptInterface(caller, Wrapper);
super.loadUrl(Config.getStartUrl());
//super.loadUrl("file:///assets/www/index2.html");
// Set by <content src="index.html" /> in config.xml
public class Caller {
private Wrapper mwrapper;
private String serverDomain;
private String serverFromIp;
private String serverToIp;
private String username;
private String password;
private WebView mWebView;
private DroidGap mGap; …Run Code Online (Sandbox Code Playgroud) 我构建一个json对象,它由在Hashmap中定义的nameValue对组成
我遇到的问题是当我调用时:
jsonObject.put(hashmap);
Run Code Online (Sandbox Code Playgroud)
它添加了nameValue对,如下所示:
name=value 代替 name:value
有什么想法吗?
谢谢
我正在尝试创建一个抽象数组方法,指定数组的这个抽象对象只能容纳3个项目.
现在我已经尝试过这样的事情,public abstract BaseAdapter[3] adapters();但它抱怨一个错误,它不能这样做.
是他们的另一种方式还是我需要做的public abstract BaseAdapter[] adapters();?
这样可以正常工作但是子类仍然可以传递大于3个项目的数组
我有一个android项目,我正在研究它,它目前不驻留在任何类型的源代码控制上.
我创建了自己的github帐户并在那里创建了一个存储库,现在我想提交并将我的android项目推送到该repo.
我怎么做?
我试过做一个git checkout但它不起作用,并说该项目不是一个git repo.
fatal: Not a git repository (or any of the parent directories): .git
Run Code Online (Sandbox Code Playgroud)
有什么建议?
嗨,我正在尝试使用支持地图片段来显示谷歌地图片段,到目前为止,没有任何喜悦信息我的项目同时拥有android-support-v4 jar和google-play-service_lib jar
这是我的布局
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<fragment
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment" />
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
我的地图活动
package com.jr.haliotest;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.util.Log;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.CameraPosition;
import com.google.android.gms.maps.model.LatLng;
import com.jr.haliotest.utils.IntentFilters;
import com.jr.haliotest.utils.Position;
/**
* @author RichardsJ
*
*/
public class MapActivity extends FragmentActivity implements IntentFilters {
private GoogleMap googleMap;
private Position mPosition;
private CameraPosition mCameraPosition;
/*
* (non-Javadoc)
*
* @see android.app.Activity#onCreate(android.os.Bundle)
*/
@Override
protected void onCreate(Bundle savedInstanceState) {
// …Run Code Online (Sandbox Code Playgroud) 是否有一个库或一段代码使一个特定的按钮就像一个正确的浏览器后退按钮,它将带你到之前加载的上一页?
目前我只是指定href我所假设的是之前加载的页面,但得出的结论是,这不起作用,因为可以从不同的屏幕访问屏幕.
是否有这样的例子,或者我是否需要创建自己的逻辑来跟踪页面历史记录?
谢谢
嗨,我正在尝试实现将两个请求链接在一起的Single Observable。
在我发出的两个请求之间,我通知回调以使用请求1的响应更新UI,然后在Schedulaers.io线程中启动下一个请求。
我遇到的问题是它也尝试从schedulars.io线程更新UI,导致ui线程中没有更新。
我在Android的RunOnUiThread代码块上冷套了calback,但想知道是否有更优雅的方法吗?
我检查了couroutines,似乎只处理将代码块放在单独的线程中。
这是我当前的代码
override fun getHomeScreenInformation() {
delegator.requestOne()
.flatMap { responseOne->
homeScreenCallBack.onResponseOneRecieved(responseOne)
delegator.requestTwo()
}
.observeOn(AndroidSchedulers.mainThread())
.subscribeOn(Schedulers.io())
.subscribe(
{responseTwo-> homeScreenCallBack.onResponseTwoRecieved(responseTwo)},
{error -> homeScreenCallBack.onError()}
)
}
Run Code Online (Sandbox Code Playgroud) 嗨,大家好我想从下面的给定文本中找出一个简单的regEx:
<b>Name:</b> Photomatix.Pro.v4.0.64bit-FOSI<br />
Run Code Online (Sandbox Code Playgroud)
我基本上只想输出和存储Photomatix.Pro.v4.0.64bit-FOSI即内部的实际值, 但当我定义它时:
private static final String REG_NAME = "<b>Name:</b>(.*)<br />";
Run Code Online (Sandbox Code Playgroud)
它实际上存储和输出整体 <b>Name:</b> Photomatix.Pro.v4.0.64bit-FOSI<br />
关于如何从上面的xml文本中提取值的任何想法?提前喝彩
我想确定一周的哪一天是一个月的第一天,但出于某种原因,它并没有让我回到正确的一周.
这是我的代码如下:
CalendarMonth[] months = CalendarUtils.constructMonthViewArray(new GregorianCalendar());
public static CalendarMonth[] constructMonthViewArray(Calendar cal) {
CalendarMonth[] months = new CalendarMonth[CALENDAR_GRID_SIZE];
int year = cal.get(cal.YEAR);
int month = cal.get(cal.MONTH);;
// calculate how many days in the month
int numOfDays = getNumOfDaysInMonth(cal);
// calculate what day(mon-sunday) is the 1st of the month
int firstDayOfMonth = getFirstDayOfMonth(cal);
private static int getFirstDayOfMonth(Calendar cal) {
int firstDay = cal.get(Calendar.DAY_OF_WEEK);
Log.d(TAG, "");
// decrement it because our array deals with values 0-6(indexes)
firstDay--;
if (firstDay == 0) { …Run Code Online (Sandbox Code Playgroud) 是否可以在正则表达式中创建OR条件.
我试图找到一个匹配包含这种类型的模式的文件名列表
第一个案例
xxxxx-hello.file
Run Code Online (Sandbox Code Playgroud)
或第二个案例
xxxx-hello-unasigned.file
Run Code Online (Sandbox Code Playgroud)
这个reg> -hello.file在第一种情况下工作正常,但是他们也可以检查第二种情况吗?
我不想创建两个正则表达式,并希望尽可能结合这两种情况.
谢谢.
嗨,当我尝试显示我的进度对话框时,我收到了一个错误的令牌窗口错误
下面是我在执行AsyncTask的活动的onCreate中的处理程序
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
progress = new ProgressDialog(getApplicationContext());
progress.setTitle(R.string.progress_title);
mHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
Log.d("", "Handling callback");
super.handleMessage(msg);
position = (Position)msg.obj;
Toast.makeText(getApplicationContext(), position.getLattitude() + " " + position.getLongetude(),
Toast.LENGTH_LONG).show();
userLocation.stopSearchLocation();
FindRestaurants findRestaurants = new FindRestaurants();
findRestaurants.execute();
}
};
}
Run Code Online (Sandbox Code Playgroud)
我的AsyncTask
class FindRestaurants extends AsyncTask<Void, Void, Void> {
@Override
protected void onPreExecute() {
// get users current location
progress.show(); //fails here
Log.d("", "onPreExecute");
if (position == null) {
position …Run Code Online (Sandbox Code Playgroud)