我想在我的Android应用程序中显示AdMob的广告.我在文档中做了所有必要的事情.但我无法运行我的应用程序,因为我的AndroidManifest.xml上有一行错误:
<activity android:name="com.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
Run Code Online (Sandbox Code Playgroud)
错误是:
error: Error: String types not allowed (at 'configChanges' with value 'keyboard|keyboardHidden|orientation|
screenLayout|uiMode|screenSize|smallestScreenSize').
Run Code Online (Sandbox Code Playgroud)
但是,如果我删除了某个值,我的应用程序正在运行,而不是广告,而是我的文本:"您必须在AndroidManifest.xml中使用configChanges声明AdActivity."
我不知道如何解决这个问题.
我正在使用android SDK 2.1和最后一个google adMob SDK 4.3.1
谢谢
我正在尝试实施Firebase远程配置:
override fun onCreate(savedInstanceState: Bundle?) {
val configSettings = FirebaseRemoteConfigSettings.Builder().setDeveloperModeEnabled(BuildConfig.DEBUG).build()
mFirebaseRemoteConfig = FirebaseRemoteConfig.getInstance()
mFirebaseRemoteConfig.setConfigSettings(configSettings)
mFirebaseRemoteConfig.setDefaults(R.xml.remote_config_defaults)
fetchRemoteConfig()
}
private fun fetchRemoteConfig() {
var cacheExpiration = 3600L
if (mFirebaseRemoteConfig.info.configSettings.isDeveloperModeEnabled) {
cacheExpiration = 0L
}
mFirebaseRemoteConfig.fetch(cacheExpiration)
.addOnCompleteListener { task ->
if (task.isSuccessful) {
Log.d(TAG, "Remote config fetch succeeded")
mFirebaseRemoteConfig.activateFetched()
} else {
Log.d(TAG, "Remote config fetch failed - ${task.exception?.message}")
}
setupView()
}
}
private fun setupView() {
val text = mFirebaseRemoteConfig.getString("my_text")
//...
}
Run Code Online (Sandbox Code Playgroud)
我的问题是并不总是调用OnCompleteListener.如果我多次关闭/打开我的应用程序,则不会始终触发setupView().
应该始终调用OnCompleteListener吗?即使我正在打缓存?
编辑:即使我禁用开发者模式,行为也是一样的.有时会触发回调,有时不会.
我是MongoDB的初学者,我正在尝试一些东西.我想存储URL并避免重复的URL我在url上创建了一个唯一的索引.像那样
collection.createIndex(new BasicDBObject("url", type).append("unique", true));
Run Code Online (Sandbox Code Playgroud)
但每次我启动我的程序时,索引再次创建不是吗?
因为,现在我的程序只插入一个URL"http://site.com",如果我重新启动我的程序,这个url会再次插入,就像没有索引一样.
每次创建索引是处理索引的错误方法吗?
这是我的代码示例
mongo.getCollection().ensureIndex(new BasicDBObject("url", 1).append("unique", "true"));
mongo.getCollection().insert(new BasicDBObject("url", "http://site.com").append("crawled", 0));
mongo.getCollection().insert(new BasicDBObject("url", "http://site.com").append("crawled", 0));
Run Code Online (Sandbox Code Playgroud)
并输出:
{ "_id" : { "$oid" : "50d627cf44ae5d6b5e9cf106"} , "url" : "http://site.com" , "crawled" : 0}
{ "_id" : { "$oid" : "50d627cf44ae5d6b5e9cf107"} , "url" : "http://site.com" , "crawled" : 0}
Run Code Online (Sandbox Code Playgroud)
谢谢
编辑:
这是我的类Mongo,它处理MongoDB导入java.net.UnknownHostException; import java.util.List; import java.util.Set;
import com.mongodb.BasicDBObject; import com.mongodb.DB; import com.mongodb.DBCollection; import com.mongodb.DBObject; import com.mongodb.MongoClient;
public class Mongo {
private MongoClient mongoClient;
private DB db;
private …
Run Code Online (Sandbox Code Playgroud) 假设我在HDFS上有这个结构:
/dir1
/dir2
/Name1_2015/
file1.lzo
file2.lzo
file3.lzo
/Name2_2015
file1.lzo
file2.lzo
Name1_2015.lzo
Run Code Online (Sandbox Code Playgroud)
我想合并'dir2'中每个目录的每个文件,并将结果追加到/dir1/DirName.lzo中的文件
例如,对于/ dir1/dir2/Name1_2015,我想合并file1.lzo,file2.lzo,file3.lzo并将其附加到/dir1/Name1_2015.lzo
每个文件都是LZO压缩的.
我该怎么做 ?
谢谢
我有一个问题使用ScrollView
内部ConstraintLayout
(constraint-layout:1.0.0-beta3
)
我的ScrollView的内容没有完全显示.
这是我的布局:
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/activity_test"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:background="#212121">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Constraint Layout"
android:textSize="45sp"/>
</LinearLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toBottomOf="@+id/header"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="BUTTON"
android:layout_marginTop="800dp"/>
</LinearLayout>
</ScrollView>
</android.support.constraint.ConstraintLayout>
Run Code Online (Sandbox Code Playgroud)
这是结果
正如您所看到的那样,按钮不可见,我到达了ScrollView的底部.
它似乎适用于LinearLayout,下面是布局
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/activity_test"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="#212121">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Linear Layout"
android:textSize="45sp"/>
</LinearLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content" …
Run Code Online (Sandbox Code Playgroud) android scrollview android-scrollview android-constraintlayout
我正在使用django并且我正在尝试设置django-roa但是当我尝试启动我的网络服务器时出现此错误 cannot import name LOOKUP_SEP
如果我django_roa
从我的INSTALLEDS_APP 删除它没关系,但我想django-roa工作,我不知道如何解决这个问题.
我不知道我能找到什么样的细节来找到解决方案.
谢谢
我想将一个字符串转换为float但我有一些问题.这是我的代码
$dataValue = $item[$data];
$dataValue = trim($dataValue);
var_dump($dataValue);echo "<br>";
$dataValue = str_replace(',', '.', $dataValue);
var_dump($dataValue);echo "<br>";
var_dump(floatval($dataValue));echo "<br>";
var_dump(floatval('4.02'));echo "<br>";
Run Code Online (Sandbox Code Playgroud)
结果
string(7) "4,02"
string(7) "4.02"
float(4)
float(4.02)
Run Code Online (Sandbox Code Playgroud)
我不明白第三个结果,为什么我有4而不是4.02?
谢谢
编辑:
我的新代码:
$dataValue = $item[$data];
echo mb_detect_encoding($dataValue) . "<br>";
$dataValue = iconv('ASCII', 'UTF-8//TRANSLIT', $dataValue);
$dataValue = trim($dataValue);
$dataValue = str_replace(',', '.', $dataValue);
echo mb_detect_encoding($dataValue) . "<br>";
var_dump($dataValue);echo"<br >";
$dataValue = mb_convert_encoding($dataValue, "UTF-8");
var_dump($dataValue);echo"<br >";
$dataValue = str_replace(',', '.', $dataValue);
$dataValue = floatval($dataValue);
var_dump($dataValue);echo"<br >";`
Run Code Online (Sandbox Code Playgroud)
结果
ASCII
ASCII
string(7) "4.02"
string(7) "4.02" …
Run Code Online (Sandbox Code Playgroud) 我想使用AsynTask来解析XML数据.所以在我的活动中:
static List<String> citations = null;
static void setCitations(List<String> data) {
citations = data;
}
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
new data().execute();
Run Code Online (Sandbox Code Playgroud)
在数据类中,我:
class data extends AsyncTask<Void, Void, List<String>> {
private XMLReader saxReader;
private SimpleContentHandler simpleContentHandler;
private List<String> citations;
@Override
protected void onPreExecute() {
Log.i("AsyncTask", "onPreExecute");
}
@Override
public void onPostExecute(List<String> citations) {
GuiguiActivity.setCitations(citations);
}
@Override
protected List<String> doInBackground(Void... params) {
citations.add("TEST 1");citations.add("TEST 2");
return citations;
}
}
Run Code Online (Sandbox Code Playgroud)
而不是citations.add我是我的XML解析器,但即使在这种情况下也会发生citations.add错误. …
我想使用XPath来获得第一个父祖先.我想解析这样的代码:
<div>
<span class="city">City 1</span>
<div class="annonce">
<span class="item">Item1</span>
</div>
</div>
<div>
<div class="annonce">
<span class="item">Item2</span>
</div>
</div>
<div>
<span class="city">City 2</span>
<div class="annonce">
<span class="item">Item3</span>
</div>
</div>
<div>
<div class="annonce">
<span class="item">Item4</span>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
有了XPath,我想得到第一个父城.例如,对于Item1,Item2我想拥有City 1而对于Item3,Item4我想拥有City 2
有可能吗?PS:我无法编辑源代码.
谢谢
我想在我的 RecyclerAdapter 上每 n 项显示一个广告。
我期待这个
|----- Item 0 -----|
|------- AD -------|
|----- Item 1 -----|
|----- Item 2 -----|
|----- Item 3 -----|
|----- Item 4 -----|
|----- Item 5 -----|
|------ ... -------|
|----- Item 15 ----|
|------- AD -------|
|----- Item 16 ----|
|------ ... -------|
Run Code Online (Sandbox Code Playgroud)
但是通过快速滚动,我可以拥有类似的东西
|----- Item 0 -----|
|------- AD -------|
|----- Item 1 -----|
|----- Item 2 -----|
|----- Item 3 -----|
|------ ... -------|
|---- Item 241 ----|
|------- AD -------| …
Run Code Online (Sandbox Code Playgroud) 我试图将一些表达式与正则表达式匹配,但它不起作用.我想匹配一个不以字母开头的字符串http://www.domain.com
.这是我的正则表达式:
^https?:\/\/(www\.)?(?!domain\.com)
Run Code Online (Sandbox Code Playgroud)
我的正则表达式有问题吗?
我希望匹配以http://开头但与http://site.com不同的表达式 .例如:
/page.html => false
http://www.google.fr => true
http://site.com => false
http://site.com/page.html => false
Run Code Online (Sandbox Code Playgroud)