我的应用程序具有浏览手机和SD卡上的文件并使用其他应用程序打开它们的功能.我想要一个解决方案,我不必指定MimeType,可以使用任何类型的文件.
这是我的代码:
Intent myIntent = new Intent(Intent.ACTION_VIEW);
myIntent.setData(Uri.fromFile(item));
startActivity(myIntent);
Run Code Online (Sandbox Code Playgroud)
但是,我收到以下错误:
android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.PICK dat=file:///sdcard/dropbox/test.pdf }
Run Code Online (Sandbox Code Playgroud) 我间歇性地得到了InflateException/ClassNotFoundException错误.我之前在SO中看到过类似的错误,但它们是由拼写错误引起的.我正确地拼写了'ImageView',所以我不知道是什么导致了错误.
发生错误的代码是:
v = View.inflate(getContext(), R.layout.event_show_row_layout, null);
Run Code Online (Sandbox Code Playgroud)
这是布局xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingLeft="10dip"
android:paddingRight="10dip" >
<TextView
android:id="@+id/fromTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="12sp"
android:textStyle="italic" />
<TextView
android:id="@+id/timeTextView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="right"
android:textSize="12sp"
android:textStyle="italic" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/layoutPostImage"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="4dp" >
<ImageView
android:id="@+id/postImageView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_margin="2dp"
android:adjustViewBounds="true"
android:background="@drawable/timeline_image_border"
android:contentDescription="@string/hello"
android:paddingBottom="6dp"
android:scaleType="fitXY"
android:src="@drawable/timeline_image_dummy" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/wordsRelativeLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/wordsTextView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical|center_horizontal"
android:paddingLeft="50dp"
android:paddingRight="50dp"
android:text="@string/hello" />
<ImageView
android:id="@+id/topLeftQuoteImageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true" …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用curl进行POST:
curl --dump-header - -H "Content-Type: application/json" -X POST --data '{"item_id": "1"}' http://www.mylocal.com:8000/api/1/bookmarks/
Run Code Online (Sandbox Code Playgroud)
但是,request.POST始终为空.
下面是我的ModelResource代码:
class BookmarkResource(ModelResource):
class Meta:
queryset = Bookmark.objects.all()
resource_name = 'bookmarks'
fields = ['id', 'tags']
allowed_methods = ['get', 'post', 'delete', 'put']
always_return_data = True
authorization= Authorization()
include_resource_uri = False
def determine_format(self, request):
return "application/json"
def obj_create(self, bundle, **kwargs):
request = bundle.request
try:
payload = simplejson.loads(request.POST.keys()[0])
except:
payload = simplejson.loads(request.POST.keys())
Run Code Online (Sandbox Code Playgroud)
谁知道我错过了什么?
提前致谢.
我有一个名为BankAccount基类的类.我也有CheckingAccount和SavingsAccount继承的类BankAccount.
BankAccount不是一个抽象类,但我不是从它创建一个对象,只是继承类.
然后,我执行这样的查询:
account = BankAccount.objects.get(id=10)
Run Code Online (Sandbox Code Playgroud)
我怎么知道,如果帐户CheckingAccount或SavingsAccount?
我现在这样做的方式是这样的:
checking_account = CheckingAccount.objects.get(id=account.id)
Run Code Online (Sandbox Code Playgroud)
如果存在,则为a CheckingAccount,否则为a SavingsAccount.
我在表单的干净方法中引发了错误(没有绑定到字段).
如何在模板中显示它们?
我尝试了{{forms.errors}}和{{form.non_field_errors}},但都没有奏效.
我到处寻找,但大多数教程都是用于创建空间数据库.是否可以将常规Postgresql数据库转换为空间数据库?
我将把它用于GeoDjango.
我在Heroku上收到以下错误:
django.core.exceptions.ImproperlyConfigured: Could not import user-defined GEOMETRY_BACKEND "geos".
Run Code Online (Sandbox Code Playgroud)
这很奇怪,因为它之前有效.
我将buildpack设置为https://github.com/dulaccc/heroku-buildpack-geodjango/.
在我的settings.py中,我有:
GEOS_LIBRARY_PATH = environ.get('GEOS_LIBRARY_PATH')
GDAL_LIBRARY_PATH = environ.get('GDAL_LIBRARY_PATH')
Run Code Online (Sandbox Code Playgroud)
当我部署到Heroku时,它似乎找到了GEOS.这是日志:
-----> Checking for GEOS
Installed
GEOS installed and accessible with env variable 'GEOS_LIBRARY_PATH'
-----> Checking for Proj.4
Installed
Proj.4 installed and accessible with env variable 'PROJ4_LIBRARY_PATH'
-----> Checking for GDAL
Installed
GDAL installed and accessible with env variable 'GDAL_LIBRARY_PATH'
Run Code Online (Sandbox Code Playgroud) 我正在尝试将String列表参数添加到多部分请求中.
使用Apache Http,我设置如下参数:
MultipartEntity mpEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
HttpPost httpPost = new HttpPost(url);
httpPost.setEntity(mpEntity);
for (User member : members) {
mpEntity.addPart("user_ids[]", new StringBody(member.id.toString()));
}
Run Code Online (Sandbox Code Playgroud)
如何在Retrofit上执行此操作?
我目前正在开发一个可嵌入页面的小部件.但是,嵌入时会影响嵌入页面的样式(字体,文本,布局等).
我想知道Clearspring和其他小部件框架如何封装他们的小部件,以免影响嵌入页面.
谢谢.
我有一个带有HeaderView的ListView.
我希望其中一个观点HeaderView能够贴在上面.
我已经看到很多关于粘性节标题的例子.
我也看了StickyScrollViewItems,但由于我使用的是ListView,我不能使用ScrollView.
有没有可用的库,或者我应该覆盖OnScrollListener的ListView?
谢谢.
我有一个带有FragmentPageAdapter的ViewPager。当显示片段时,我希望它开始播放动画(在片段中淡入视图)。
但是,动画运行不一致,当我向左/向右滑动时,动画每隔几页运行一次。我想我需要在onPageSelected事件上启动动画,但是我不知道如何获取片段并启动动画。
我的代码如下。TourFragment是我使用FragmentPageAdapter添加到ViewPager的片段,而TourActivty包含ViewPager。
巡回片段
public class TourFragment extends Fragment {
Tour tour;
ImageView ivTitle;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.fragment_tour,
container, false);
RelativeLayout rlImageContainer = (RelativeLayout) v.findViewById(R.id.tour_image_container);
Resources resources = getActivity().getResources();
ivTitle = (ImageView) v.findViewById(R.id.tour_title);
ivTitle.setImageDrawable(resources.getDrawable(tour.getDrawableTitleId()));
Animation fadeInAnimation = AnimationUtils.loadAnimation(getActivity(), R.anim.fadein);
ivTitle.startAnimation(fadeInAnimation );
return v;
}
@Override
public void onResume() {
super.onResume();
Animation fadeInAnimation = AnimationUtils.loadAnimation(getActivity(), R.anim.fadein);
ivTitle.startAnimation(fadeInAnimation );
}
public static Fragment newInstance(Tour tour) {
TourFragment f = new TourFragment();
f.tour …Run Code Online (Sandbox Code Playgroud) 我有以下型号.如何从Entity表中访问继承表(Team和Athete)的unicode?我正在尝试显示所有显示"名称"的实体的列表,如果Team和'firstname'和'lastname',如果运动员.
class Entity(models.Model):
entity_type_list = (('T', 'Team'), ('A', 'Athlete'))
type = models.CharField(max_length=2, choices=entity_type_list,default='P')
pictureurl = models.URLField('Picture Url', verify_exists=False, max_length=255, null=True, blank=True)
class Team(Entity):
name = models.CharField(max_length=100)
def __unicode__(self):
return self.name
class Athlete(Entity):
firstname = models.CharField(max_length=100)
lastname = models.CharField(max_length=100)
def __unicode__(self):
return '%s %s' % (self.firstname, self.lastname)
Run Code Online (Sandbox Code Playgroud) android ×6
django ×6
inheritance ×2
python ×2
css ×1
django-forms ×1
geodjango ×1
heroku ×1
postgis ×1
postgresql ×1
retrofit ×1
subclass ×1
tastypie ×1
widget ×1