我有一个ImageView,我希望它总是相同的大小.如果图像小于视图,我希望它在视图中居中.如果图像大于视图,那么我希望它缩小 - 保留纵横比.
我自己也有过几次尝试 - 其中最新的是:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ImageView android:id="@+id/itemImage" android:layout_width="100dp"
android:layout_height="100dp" android:scaleType="fitCenter"
android:adjustViewBounds="true" android:gravity="center" android:padding="10px" />
<TextView android:id="@+id/currentLentItem" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:padding="10px"/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
我在这里错过了什么?
我用单声道(C#)编写了一个简单的应用程序,它使用NHibernate和MYSQL - 现在我想把它移植到SQLite.
我希望我能简单地改变hibernate.cfg.xml并将其指向不同的数据库.这是我修改过的hibernate.cfg.xml:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2" >
<session-factory name="NHibernate.Test">
<property name="connection.driver_class">NHibernate.Driver.SQLite20Driver</property>
<property name="connection.connection_string">
Data Source=nhibernate_test.db;Version=3
</property>
<property name="dialect">NHibernate.Dialect.SQLiteDialect</property>
<property name="query.substitutions">true=1;false=0</property>
<property name="proxyfactory.factory_class">NHibernate.ByteCode.LinFu.ProxyFactoryFactory, NHibernate.ByteCode.LinFu</property>
</session-factory>
</hibernate-configuration>
Run Code Online (Sandbox Code Playgroud)
问题是我收到一个错误,它无法找到System.Data.SQLite.这并不让我感到惊讶,因为据我所知,单声道我们应该使用Mono.Data.SQLite.
问题是(假设我正确理解了问题)我不知道如何告诉NHibernate使用Mono.Data.SQLite而不是System.Data.SQLite.
这一切都是在Linux上完成的 - 如果这有任何区别的话.
有没有人有任何想法如何进行?
我非常乐意编写应用程序.然而,我是图标设计的垃圾.我敢肯定,我不是唯一一个对他们来说,这是一个问题 - 但所有的Android开发者需要创建一个启动器图标.
有没有人有任何关于敲击简单但有效的发射器图标的好建议?
我正在尝试用ABS来恢复我的应用程序的ICS外观和感觉.获取ActionBar本身很好,很简单,但是添加菜单项却没有.
我的代码看起来像:
@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
MenuInflater inflater = getSupportMenuInflater();
inflater.inflate(R.menu.menu, menu);
return true;
}
Run Code Online (Sandbox Code Playgroud)
正在使用所有适当的进口.
我的menu.xml如下:
<?xml version="1.0" encoding="utf-8"?>
<menu
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/backup" android:title="@string/backupLabel"/>
<item android:id="@+id/restore" android:title="@string/restoreLabel"/>
</menu>
Run Code Online (Sandbox Code Playgroud)
ActionBar显示,但菜单表现为2.1菜单 - 仅从菜单按钮激活,没有溢出.在ICS仿真器上也是如此 - 我必须使用菜单按钮激活菜单.
如果我添加android:showAsAction ="ifRoom",那么这些项目将显示为操作项目 - 但不会出现溢出,这是我希望它们始终存在的位置.
这一切都有意义吗?
我错过了什么?
我的应用中有一个活动,只显示搜索的一些结果.使用ListView显示此数据.这很好用.我最近尝试在其下添加Adview,但它根本不显示.更重要的是,它将我的列表视图推到屏幕顶部,这样它只能占据屏幕的前20%左右 - 只有空白.
这是显示XML:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:myapp="http://schemas.android.com/apk/res/uk.co.redfruit.android.whogotwhat"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="10dp"
android:paddingBottom="10dp"
>
<ListView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/scanResults"
android:paddingLeft="5dp"
android:paddingRight="5dp"
/>
<com.admob.android.ads.AdView
android:id="@+id/ad"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
myapp:backgroundColor="#000000"
myapp:primaryTextColor="#FFFFFF"
myapp:secondaryTextColor="#CCCCCC"
/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
我在这里错过了什么?
我正在尝试根据用户在我的Android应用程序中显示的表单创建PDF文档.我使用以下代码创建PDF文件,然后将其附加到电子邮件中:
public static File generate(View salesFragmentTableLayout, Context context) throws KingdomSpasException {
Builder printAttrsBuilder = new Builder();
printAttrsBuilder.setMediaSize(PrintAttributes.MediaSize.ISO_A4);
printAttrsBuilder.setMinMargins(new Margins(5, 5, 5, 5));
PrintedPdfDocument document = new PrintedPdfDocument(context, printAttrsBuilder.build());
PageInfo pageInfo = new PageInfo.Builder(150, 150, 1).create();
Page page = document.startPage(pageInfo);
salesFragmentTableLayout.draw(page.getCanvas());
document.finishPage(page);
File result = null;
try {
result = File.createTempFile("Kingdom Spas Agreement", ".pdf", context.getCacheDir());
document.writeTo(new BufferedOutputStream(new FileOutputStream(result)));
} catch (FileNotFoundException e) {
throw new KingdomSpasException("Failed to find relevent file", e);
} catch (IOException e) {
throw new KingdomSpasException("IO Problem occured …Run Code Online (Sandbox Code Playgroud) 我正在尝试编写一个非常简单的JMS应用程序来部署在Glassfish上,以此来了解JMS.
在类中发送消息我有以下内容:
@Resource(mappedName="jms/MyConnectionFactory")
public static QueueConnectionFactory factory;
@Resource(mappedName="jms/MyQueue")
public static Queue queue;
Run Code Online (Sandbox Code Playgroud)
这会导致NullPointer,这是我第一次尝试访问工厂.但是,如果我尝试使用JNDI查找对象,它可以正常工作.这个类只是一个POJO,由一个在简单的Web应用程序中运行的JSP访问.
是因为它是一个POJO而不是,例如,这是一个失败的servlet?
我曾经认为它在Glassfish中部署和运行的事实就足够了 - 显然我错了......
我正在尝试使用ActionBar构建一个应用程序(带有"向上"按钮),但我完全没有正确地包含appcompat-v7库.
我正在使用Eclipse.我不想简单地使用Android Studio,因为我曾尝试多次切换到Idea,并且从未像Eclipse那样舒服.
我已经按照d.android.com上的官方说明进行操作,但我没有让它工作.我也广泛搜索并遵循那里发现的建议 - 包括这里的几个主题.
我得到的结果是Eclipse(Fragment,ActionBarActivity等)是由Eclipse找到的,但像主题这样的东西却没有.如果不使用Theme.Appcompat.*主题,我无法正确部署我的应用程序.我尝试设置时遇到的错误android:theme="@android:style/Theme.AppCompat.Light.DarkActionBar"是错误:
Error: No resource found that matches the given name (at 'theme' with value '@android:style/
Theme.AppCompat.Light.DarkActionBar').
Run Code Online (Sandbox Code Playgroud)
在我写这篇文章时,我想到的可能是我的问题更多的是我试图设置主题而不是appcompat库 - 但我不会假设,希望有人可以帮我弄清楚我哪里出错了.
有趣的是,每当我尝试部署我的应用程序时,eclipse控制台中都会出现以下错误:
[2013-08-28 15:20:07 - android-support-v7-appcompat] Could not find android-support-v7-appcompat.apk!
Run Code Online (Sandbox Code Playgroud)
以下是一些屏幕截图,显示了我的应用程序的属性以及我如何尝试包含appcompat库,该库已导入我的Workspace并已设置为Android库.

