我正在创建一个应用程序,我必须在页脚视图中添加进度对话框,但我无法在页脚视图中获得任何进度对话框:
主要活动:
我想在这个类的页脚中添加进度对话框
public class MainActivity extends Activity implements OnScrollListener {
// All variables
XmlParser parser;
Document doc;
String xml;
ListView lv;
ListViewAdapter adapter;
ArrayList<HashMap<String, String>> menuItems;
ProgressDialog pDialog;
private String URL = "http://api.androidhive.info/list_paging/?page=1";
// XML node keys
static final String KEY_ITEM = "item"; // parent node
static final String KEY_ID = "id";
static final String KEY_NAME = "name";
ProgressDialog dialog;
// Flag for current page
int current_page = 1;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
lv = …Run Code Online (Sandbox Code Playgroud) 嗨,我想让我的地图放大到我当前的位置.当前通过向仿真器发送lat和long来定义当前位置.我该怎么做呢?
我目前的mapactivity.java
public class MapsActivity extends MapActivity {
private MapView mapView;
private MyLocationOverlay myLocOverlay;
MapController mc;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.mapactivity);
initMap();
initMyLocation();
}
/**
* Initialise the map and adds the zoomcontrols to the LinearLayout.
*/
private void initMap() {
mapView = (MapView) findViewById(R.id.mapView);
View zoomView = mapView.getZoomControls();
LinearLayout myzoom = (LinearLayout) findViewById(R.id.zoom);
myzoom.addView(zoomView);
mapView.displayZoomControls(true);
mapView.getController().setZoom(17);
}
/**
* Initialises the MyLocationOverlay and adds it to the …Run Code Online (Sandbox Code Playgroud) 我正在制作小型气球游戏.气球随机弹出并在一段时间后消失.当我点击它们时,我想要消失它们并显示+1而不是气球.当我点击气球时,我想要取消气球精灵.我的问题是当我在代码中调用sprite.detachSelf()时,精灵只是消失了,但实际上精灵还没有被删除.它只会变得无形.当我再次点击那个地方时,气球就会出现,即使在气球消失后它也会显示+1.这意味着我认为气球没有正确脱落.
这是我的代码:
@Override
protected Scene onCreateScene() {
//this.mEngine.registerUpdateHandler(new FPSLogger());
scene = new Scene();
backgroundSprite = new Sprite(0, 0, this.mBackgroundTextureRegion,
getVertexBufferObjectManager());
backgroundSprite.setSize(CAMERA_WIDTH, CAMERA_HEIGHT);
scene.attachChild(backgroundSprite);
scene.unregisterTouchArea(backgroundSprite);
text = new Text(0, 0, font, "Score : 00",
getVertexBufferObjectManager());
scene.attachChild(text);
textTime = new Text(displayMetrics.widthPixels - 220, 0, font,
"00 : 60", getVertexBufferObjectManager());
scene.attachChild(textTime);
timer = new TimerClock(1, new TimerClock.ITimerCallback() {
TimerClock t = timer;
public void onTick() {
System.out.println("timer inside");
if (time > 0) {
time = time - 1;
System.out.println("timer inside : " + …Run Code Online (Sandbox Code Playgroud) 我需要编写很多简单的模块,我不想隐藏它们之间的主要模块.出于这个原因,我希望有一个像这样的目录树:
Project
|-module1
|-module2
+-directory
|-module3
|-module4
+-module5
Run Code Online (Sandbox Code Playgroud)
问题:如果我在新文件夹中移动模块,Android Studio找不到它们.
所以,我的问题是:如何在目录中移动模块?
我正在使用aSmack.我的应用程序侦听聊天室并对消息作出反应,但它从不发送消息.如果聊天室在一段时间内保持静默状态然后发送新消息,则应用程序不会收到更多消息.我研究过,我认为XEP-0199就是这里的解决方案.我看到@Flow(当前的Smack维护者)实现了它并且相关问题已经关闭.
我认为我需要使用,PingProvider但我真的不知道如何连接这个类Connection.
如何启用XEP-0199?我该怎么用PingProvider?
连接代码:
smack = SmackAndroid.init(getActivity().getApplicationContext());
connection = new XMPPConnection(App.getServer());
connection.addConnectionListener(new ConnectionListener() {
private final static String SMACK = "SMACK";
@Override
public void reconnectionSuccessful() {
Log.i(SMACK , "reconnectionSuccessful");
}
@Override
public void reconnectionFailed(Exception e) {
Log.i(SMACK, "reconnectionFailed", e);
}
@Override
public void reconnectingIn(int seconds) {
Log.i(SMACK, "reconnectingIn " + seconds);
}
@Override
public void connectionClosedOnError(Exception e) {
Log.i(SMACK, "connectionClosedOnError", e);
}
@Override
public void connectionClosed() …Run Code Online (Sandbox Code Playgroud) 我刚刚发现PackageInfo.versionCode在Android Pie中已弃用.他们指向你使用PackageInfo.getLongVersionCode().这种新方法的JavaDoc是:
返回
versionCode并versionCodeMajor组合在一起作为单个long值.在versionCodeMajor被放置在高32位.
但是什么versionCodeMajor呢?我该如何使用它?versionCodeMajor和旧有versionCode什么区别?
它的文档几乎没有说:
内部主要版本代码.这基本上是基本版本代码的额外高位; 没有其他意义,因为更高的数字是最近的.这不是通常向用户显示的版本号,通常由R.attr.versionName提供.
它是否可以注入一个匿名类?我有以下错误:
java.lang.IllegalArgumentException:没有为members/com.acme.MyFragment $ 1注册注入.您必须将其显式添加到其中一个模块的"注入"选项中.
例:
public class MyFragment extends Fragment {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
new MyTrask(getActivity()) {
protected void onPostExecute(String result) {
// Stuff
}
}.execute();
}
}
public class MyTask extends AsyncTask<Void, Void, String> {
@Inject
UserApi userApi;
public MyTask(Context context) {
App.getInstance().inject(this);
}
@Override
protected String doInBackground(Void... params) {
return "Hello World!";
}
}
Run Code Online (Sandbox Code Playgroud) 我有一个发出数据页的流A, B, C, D...。我可以使用哪个运算符来获取这样的流:[A], [A, B], [A, B, C], [A, B, C, D]...?
我知道collect或toList但它们只在流末尾发出一次。
I\xe2\x80\x99m 尝试在物料清单 (BoM) 平台模块中定义所有依赖项,以便我的多模块项目中的其他模块可以使用相同的版本。除了 kapt 依赖项之外,一切正常。在那些我得到这个错误:
\n\nCould not determine the dependencies of task ':app:kaptDebugKotlin'.\n> Could not resolve all task dependencies for configuration ':app:kapt'.\n > Could not find com.google.dagger:dagger-compiler:.\n Required by:\n project :app\nRun Code Online (Sandbox Code Playgroud)\n\n例如,使用此平台 ( :bom) 模块:
plugins {\n id 'java-platform'\n}\ndependencies {\n constraints {\n api 'com.google.dagger:dagger:2.25.2'\n api 'com.google.dagger:dagger-compiler:2.25.2'\n }\n}\nRun Code Online (Sandbox Code Playgroud)\n\n当我在应用程序模块中像这样使用它时,我收到该错误:
\n\ndependencies {\n implementation platform(project(':bom'))\n implementation 'com.google.dagger:dagger'\n kapt 'com.google.dagger:dagger-compiler'\n // ...\n}\nRun Code Online (Sandbox Code Playgroud)\n\n如果我使用 .I\xe2\x80\x99m 会出现相同的错误annotationProcessor。kapt 'com.google.dagger:dagger-compiler:2.25.2'如果我像所有作品一样设置版本。
我究竟做错了什么?我可以将 BoM 用于kapt或 …
android gradle annotation-processing android-gradle-plugin kapt
我有一个TextView显示背景图片.
我需要根据条件显示或隐藏此图像(如果x = 1显示图像,否则隐藏图像).我正在使用代码:
t1.setBackgroundResource(R.drawable.ficha);
Run Code Online (Sandbox Code Playgroud)
它显示了图像.
但我不知道如何隐藏它.
现在我有这个代码:
TextView textView = (TextView) convertView.findViewById(R.id.label);
String html = name + " - <small>" + description + "</small>";
textView.setText(Html.fromHtml(html));
Run Code Online (Sandbox Code Playgroud)
textView有的地方android:textAppearance="?android:attr/textAppearanceLarge".但我需要的是<small>放置textApparence的实例android:textAppearance="?android:attr/textAppearanceSmall".我怎样才能做到这一点?
在大多数设备中,调用context.getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS)返回Path Android/data/com.XXXX.YYY/files/Download.但是在使用相同APK的运行Android 2.2.1的三星GT-P1010上,此调用将返回external_sd/Android/data/com.XXXX.YYY/files/Download.我需要在所有设备中使用相同的路径.我怎样才能获得它?