我正在尝试创建一个非常基本的聊天屏幕,其中ListView显示文本,底部是EditText,EditText右侧是"发送"按钮.一切都很实用,但当我点击EditText时,虚拟键盘会覆盖它.屏幕平移一点但不足以在键盘上方可见.我的清单中有"adjustPan"标签,并且还尝试了"adjustResize"标签无效.我猜这与我的布局设置方式有关,但老实说我没有任何线索.请帮忙!
当前布局......
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ListView android:id="@+id/android:list"
android:layout_height="0dip"
android:layout_width="fill_parent"
android:layout_weight="1"
android:stackFromBottom="true">
</ListView>
<LinearLayout android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<EditText android:id="@+id/sendMessageBox"
android:focusable="true"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:scrollbars="vertical"
android:maxLines="4"
android:text=""
android:inputType="textShortMessage|textAutoCorrect|textCapSentences|textMultiLine"
android:maxLength="1000"
android:hint="Type your message..."
android:imeOptions="actionSend"/>
<Button android:id="@+id/sendMessageButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:text="Send"/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
android android-manifest android-layout android-softkeyboard
我在Android文档中读到,通过将我的Activity的launchMode属性设置为singleTop或者通过向FLAG_ACTIVITY_SINGLE_TOP我的Intent 添加标志,该调用startActivity(intent)将重用单个Activity实例并在onNewIntent回调中给我Intent .我做了这两件事,每次都onNewIntent不会发射和onCreate射击.文档还说,它this.getIntent()返回首次创建时首次传递给Activity的意图.在onCreate我打电话getIntent,每一次(我创建另一个动作的意图对象,并增加一个额外的给它我得到一个新的...这额外的应该是相同的,每次如果它回到我同样的意图对象).所有这些让我相信我的活动并不像"单一顶级",我不明白为什么.
为了添加一些背景,以防我只是错过了一个必需的步骤,这里是清单中的Activity声明和我用来启动活动的代码.活动本身没有做任何值得一提的事情:
在AndroidManifest.xml中:
<activity
android:name=".ArtistActivity"
android:label="Artist"
android:launchMode="singleTop">
</activity>
Run Code Online (Sandbox Code Playgroud)
在我的通话活动中:
Intent i = new Intent();
i.putExtra(EXTRA_KEY_ARTIST, id);
i.setClass(this, ArtistActivity.class);
i.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
startActivity(i);
Run Code Online (Sandbox Code Playgroud) java android android-manifest android-intent android-activity
我想创建自己的活动作为主要活动,而不是使用默认MainActivity.
如何在android清单中定义它?
在最新版本的ADT(版本20预览版3)中,他们说可以使库的清单文件与使用它们的项目合并:
将库项目清单文件自动合并到包含项目的清单中.使用manifestmerger.enabled属性启用.
我如何以及在何处使用它?我无法在任何地方看到内容帮助我.
我在我的项目中使用Google Maps v2 API.在Google Maps v2中,调试/发布API密钥定义于AndroidManifest.xml.我已经看到了链接,但在该映射键中是在xml布局文件中定义的AndroidManifest.xml.那么我可以为我的项目定义调试和释放密钥AndroidManifest.xml吗?
我想要这样的东西AndroidManifest.xml:
如果是调试模式:
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="@string/debug_map_api_key"/>
Run Code Online (Sandbox Code Playgroud)
如果发布模式:
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="@string/release_map_api_key"/>
Run Code Online (Sandbox Code Playgroud) android google-maps key android-manifest google-maps-android-api-2
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="ac.tec.oop.ahorcado.android"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="7"
android:targetSdkVersion="16"/>
<application android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme">
<activity android:label="@string/app_name"
android:name="ac.tec.oop.ahorcado.android.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
</manifest>
Run Code Online (Sandbox Code Playgroud)
这些行给了我"无法解决符号错误",即使它们需要被引用的包清楚地写出来.我试图解决这个问题几个小时,但我不知道还能做什么.我正在使用Android Studio,它给我带来了很多问题.
android:icon="@drawable/ic_launcher
android:label="@string/app_name"
android:theme="@style/AppTheme">
android:name="ac.tec.oop.ahorcado.android.MainActivity">
Run Code Online (Sandbox Code Playgroud) 我将包名从com.mycompany.myapplication更改为com.mycompany.testapp.
一切都很好,但当我尝试在模拟器上运行它时,我得到:
会话重启目标设备:NexusS [emulator-5554]上传文件本地路径:/home/antony/AndroidStudioProjects/testappProject/testapp/build/apk/testapp-debug-unaligned.apk远程路径:/ data/local/tmp/com.mycompany.myapplication安装com.mycompany.myapplication DEVICE SHELL命令:pm install -r"/data/local/tmp/com.mycompany.myapplication"pkg:/data/local/tmp/com.mycompany.myapplication成功
启动应用程序:com.mycompany.myapplication/com.mycompany.testapp.MainActivity.DEVICE SHELL COMMAND:我开始-D -n"com.mycompany.myapplication/com.mycompany.testapp.MainActivity"-a android.intent.action.MAIN -c android.intent.category.LAUNCHER开始:Intent {act = android .intent.action.MAIN cat = [android.intent.category.LAUNCHER] cmp = com.mycompany.myapplication/com.mycompany.testapp.MainActivity}错误类型3错误:活动类{com.mycompany.myapplication/com.mycompany .testapp.MainActivity}不存在.
注意远程路径^^^是错误的.
如果我去模拟器,我可以从菜单启动应用程序,只是当我尝试从Android Studio运行应用程序时出现此错误.
我也在logcat中看到,在右上角,下拉列表为我提供了"No Filters"或"app:com.mycompany.myapplication".所以我甚至无法正常调试.
这些对com.mycompany.myapplication的引用来自何处,以及如何解决这个问题?
我有这个AndroidManifest.xml文件:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
android:versionCode="1" android:versionName="1.0.0.0721"
android:process="com.lily.process" package="com.lily.test">
<provider android:authorities="com.lily.test"
android:name="com.lily.test.provider"
android:process="com.lily.process">
</provider>
Run Code Online (Sandbox Code Playgroud)
"android:process"作为清单标记和提供者标记添加,我知道如果它被添加为提供者标记,则提供者可以在"com.lily.process"过程中运行.但是当它作为清单标签编写时,它的用法是什么?我尝试过,但并非所有组件都可以在它识别的过程中运行.
我想在我的主要活动中创建一个广播接收器作为内部类.但我在清单xml文件中定义广播接收器时遇到问题,因为android无法找到它.
码:
public class MyActivity extends Activity{
...
public class Receiver extends BroadcastReceiver{
@Override
public void onReceive(Context context, Intent intent) {
....
}
}
...
}
Run Code Online (Sandbox Code Playgroud)
表现:
<receiver android:name=".org.danizmax.myapp.MyActivity$Receiver" android:enabled="true">
<intent-filter>
<action android:name="org.danizmax.myapp.BROADCAST_INITIAL_DATA"></action>
</intent-filter>
</receiver>
Run Code Online (Sandbox Code Playgroud)
我尝试过:
我看到其他人也有类似的问题,但没有找到任何答案.
那有可能吗?如果没有,有什么更好的方式来使用广播接收器?
谢谢!
我最近创建了一个项目并添加了一个启动和主要活动.我编辑了清单文件,并将启动活动和主要活动添加到其中.添加主活动后,它会向我发出警告"导出的活动不需要权限".这给了我什么警告?我的API版本是android:15.
请帮帮忙,谢谢!
这是我的清单文件!
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.sliit.droidman"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="10" android:targetSdkVersion="15" />
<application android:label="@string/app_name"
android:icon="@drawable/ic_launcher"
android:theme="@style/AppTheme">
<activity
android:name=".SplashActivity"
android:label="@string/app_name"
android:theme="@android:style/Theme.NoTitleBar">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity
android:name="com.sliit.droidman.main.MainActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="com.sliit.droidman.main.MAINACTIVITY" />
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
</application>
</manifest>
Run Code Online (Sandbox Code Playgroud)