我有两个网格视图,我想为其创建自定义动画.想象一下这个布局:
___________________________________________ | | | | | TOP Grid | | | |_________________________________________| | | | | | BOTTOM | | Grid | | | |_________________________________________|
底部网格将在顶部网格后面"滑出"和"滑动".我想我应该使用翻译动画.如何找出fromX和fromY值?我以为我可以同时在布局中查看,然后将动画设置为RelativeToParent.
这是正确的方法吗?如果您知道任何地方我可以找到此功能的源代码,我将非常感激.谢谢,
更新:我打开了一个问题,如果您遇到同样的问题,请为其加注. http://code.google.com/p/android/issues/detail?id=28016
我有一个带有gridview的appwidget.
当我开始向我的小部件添加项目时,几乎总是我得到两次显示的第一个项目(而不是显示第一个项目和第二个项目).
如果我做一个小部件更新意图,那么问题是固定的,永远不会返回(假设我的gridview上已经有两个项目).
但总是在添加前两个项目时发生.
任何想法可能是什么?
更新:我刚刚注意到,当一个新项目添加到GridView时,它总会发生.如果我在不添加新项目的情况下刷新小部件,那么它可以正常工作.
我看到的另一件事是getViewAt方法总是为第一个项目(位置零)调用两次.也许它有关系?
我非常密切地关注这里的示例:http: //developer.android.com/resources/samples/WeatherListWidget/src/com/example/android/weatherlistwidget/WeatherWidgetService.html
这是我的RemoteViewsService,我认为这是相关的部分,但我不确定.还有什么可以影响它?
package com.manor.TestApp;
public class TestAppRemoteViewsService extends RemoteViewsService {
@Override
public RemoteViewsFactory onGetViewFactory(Intent intent) {
return new TestAppViewsFactory(this.getApplicationContext(), intent);
}
}
class TestAppViewsFactory implements RemoteViewsService.RemoteViewsFactory {
private Context mContext;
//private int mAppWidgetId;
private TestDb mDb = null;
private int mCount = 0;
private String[] mData;
public TestAppViewsFactory(Context context, Intent intent) {
mContext = context;
/*mAppWidgetId = intent.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID,
AppWidgetManager.INVALID_APPWIDGET_ID);*/
}
@Override
public void onCreate() {
mDb …Run Code Online (Sandbox Code Playgroud) 我有一个GridView在我的应用程序中,我想显示文本和复选框就像电子邮件收件箱页面.我使用了一个适配器,但当我显示超过15个元素时,顶行的文本和复选框消失,所以当我再次向上滚动它们时,它们是不可见的.这是我的代码
public class EmployeeAdaptor extends BaseAdapter {
Context context;
String [] table;
int pos;
int formatOfTable;
public EmployeeAdaptor(Context c,String []tab,int numberOfItems,int format, boolean[] sel) {
context = c;
table = tab;
items = numberOfItems;
formatOfTable = format;
//ifformat is 0 then show text view in first column
//if it is 1 then show radio button in first column
//if it is 2 then show check box in first column.
pos = 0;
}
public int getCount() {
// …Run Code Online (Sandbox Code Playgroud) 我的主布局中有一个 GridView,如下所示:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<GridView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/gridview"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center"
android:horizontalSpacing="1dp"
android:stretchMode="columnWidth"
android:verticalSpacing="1dp" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
产生这样的网格

每个单元格的内容是这样的布局:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="@drawable/btn_measurement" >
<Button
android:id="@+id/numerical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="---" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
但我希望第 4 列是其他列的三分之一,但我不能。
我检查了链接:
具有不同列大小的GridView和Android GridView 列拉伸
但他们没有帮助。:(
如果您认为我需要完全更改我的解决方案,请比仅提供一般线索更准确。谢谢
我正在实现一个应用程序,它在一个活动中包含图像的网格视图,每个图像包含一个片段,其中包含全屏图像.当我点击网格中的任何图像时,它应该打开相应的片段.但是,我们不能使用意图来做到这一点.这是我的代码
public void onItemClick(AdapterView<?> arg0, View arg1, int position,
long arg3) {
// TODO Auto-generated method stub
if(position==0)
{
Intent i=new Intent(Gallery.this,ImageFrag1.class);
startActivity(i);
}
Run Code Online (Sandbox Code Playgroud)
而片段是
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
public class ImageFrag1 extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.imagefrag1, container, false);
}
}
Run Code Online (Sandbox Code Playgroud)
此片段绑定到活动ImagesSwipe.那么我如何实现网格视图项与其相应片段之间的转换.谢谢
我必须使用 Gridview 创建 UI。图像是动态的,因为它来自 webservice 。
我可以使用 xml 定义列号,但第零个索引处的项目必须有一个完整的图像,然后其余部分应分为列。
任何帮助表示赞赏。
I know this is already been asked, but somehow the solutions do not work for me.
I have a gridView which is inflated by a relativeLayout. The adapter sets perfectly, When I add a clickListener to one of the childs of relativeLayout they also work fine. But not the itemClickListener on the gridview.
Here is what I have tried:
Gridview:
<GridView
android:id="@+id/gridView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:clickable="true"
android:clipToPadding="true"
android:columnWidth="170dp"
android:fitsSystemWindows="true"
android:focusable="true"
android:numColumns="auto_fit"
android:stretchMode="columnWidth" >
</GridView>
Run Code Online (Sandbox Code Playgroud)
Relativelayout added in gridview: …
我有一个GridView实现并激活了
mGridView.setChoiceMode(GridView.CHOICE_MODE_MULTIPLE_MODAL);
Run Code Online (Sandbox Code Playgroud)
模式.现在,当我对一个项目执行长按时,我可以从网格中选择多个项目.我希望通过正常的短按实现此行为.这可能吗?
我目前正在尝试从自定义元素(取自数据库)创建 Android 网格布局,并且需要有关如何实现它的建议。网格应该有 6 列,并且应该垂直滚动。每个网格元素(Item)都有columnSpan、columnRow、xPosition和yPosition。
我尝试使用 GridLayout,但没有适配器支持。我尝试使用网格视图,但无法使其看起来正确。我需要一个强大的解决方案,但此时我迫切需要一个可行的解决方案。
这是一篇旧帖子,其中包含过于复杂的解决方案。有什么改变吗?这个问题有好的解决办法吗?为什么这个问题首先存在?
android gridview grid-layout android-gridview android-gridlayout
我基本上是颤振的新手。我想显示来自特定路径的图像,例如“Storage/WhatsApp/Media/”。我想在网格视图中显示所有图像。我怎样才能在颤振中实现这一目标。我见过很多例子,但每个人都在使用资产文件夹。这是获取路径的代码。如何在网格视图中显示它们?
Future<String> get localpath async
{
final dir=await getExternalStorageDirectory();
return dir.path;
}
Future<File> get localfile async{
final path=await localpath;
return File('$path/WhatsApp/Media/WhatsApp Images');
}
Future<String> readData() async{
try{
final file=await localfile;
String image_path=await file.readAsString();
return image_path;
}
catch(e) {return e.toString();}
}
Run Code Online (Sandbox Code Playgroud)
现在既然我得到了如何在 gridview 中显示图像的路径?我应该使用 gridview.builder 吗?
android ×10
android-gridview ×10
gridview ×3
column-width ×1
datagridview ×1
file ×1
flutter ×1
grid-layout ×1