你好我想在默认情况下显示另一个启动画面,如果应用程序第一次启动(安装后如右)
所以我写了这个.但是新的Activity没有启动它停留在Splash屏幕上.有人可以说它有什么不对吗?
import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.widget.TextView;
public class splash extends Activity {
private Thread splashTread;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.splash);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
if(!prefs.getBoolean("firstTime", false)) {
// run your one time code
Intent i = new Intent(splash.this, main.class);
startActivity(i);
SharedPreferences.Editor editor = prefs.edit();
editor.putBoolean("firstTime", true);
editor.commit();
// thread for displaying the SplashScreen
splashTread = new Thread() {
@Override
public void run() {
try …Run Code Online (Sandbox Code Playgroud) 我正在使用以下代码缩放我的webview以使内容适合屏幕的宽度:
webView.getSettings().setLoadWithOverviewMode(true);
webView.getSettings().setUseWideViewPort(true);
webView.getSettings().setBuiltInZoomControls(true);
Run Code Online (Sandbox Code Playgroud)
这有效,但现在我在内容的底部得到一个空白区域.空白空间的大小(高度)与其正在进行的缩放的大小成正比.因此对于较小的设备,尺寸更大.
我的感觉是在缩放生效后没有重新计算滚动条大小.这个假设是由于当通过点击屏幕放大和缩小时,空的空间消失了.虽然这适用于Android 2.3但不适用于4.0.
我的问题是如何在缩放后强制滚动条重新计算.还是有其他解决方案.
谢谢.
PS以下是我在xml中定义webview的方法
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="#FFFFFF" >
<WebView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/web_view"
android:background="#AAFFFFFF"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</ScrollView>
Run Code Online (Sandbox Code Playgroud) DIR * d;
int dsize=0;
struct dirent * de;
char *dir[1024];
d=opendir(".");
while ((de = readdir(d)))
{
if((de->d_type) & DT_DIR)
{
dir[dsize]= de->d_name;
dsize++;
}
}
Run Code Online (Sandbox Code Playgroud)
我正在尝试将文件名的地址存储到char指针数组中.
指针有点生疏我回去看了一些指针评论的页面,但我不确定我做错了什么..继续告诉我"警告:赋值从指针生成整数而没有强制转换".我的语法是否因为结构而关闭?
我对这个问题感到很疯狂.
我有这个自定义的结构
struct oneRectangle
{
QString partName;
QGraphicsRectItem * rectangle;
};
Run Code Online (Sandbox Code Playgroud)
我有一个List使用这个结构作为模板:
QList<oneRectangle> partList;
Run Code Online (Sandbox Code Playgroud)
在我追加struct的实体(没有init指针)后,我需要做这样的事情:
partList.at(index).rectangle = some pointer points to a QGraphicsRectItem
Run Code Online (Sandbox Code Playgroud)
但是,我得到一个错误,说结构是一个只读结构.我首先尝试malloc指针,然后将其附加到列表中,但是当我为指针分配地址时,我仍然得到错误.这有什么问题?