标签: android-gridview

在GridView(Android)中加载异步图像

我有一个GridView图片/文本,从不同的服务器加载(我只知道URL).我试图根据ryac的教程修改我的代码.

在我的Activity文件中,我设置GAdapter为我GridView喜欢这样:

GridView mGridMain = (GridView)findViewById(R.id.gvMain);
mGridMain.setAdapter(new GAdapter(this, listAppInfo));
Run Code Online (Sandbox Code Playgroud)

我修改了自己的适配器并尝试调整它:

public class GAdapter extends BaseAdapter {

 private Context mContext;
 private List<SiteStaff> mListAppInfo;
 private HashMap<Integer, ImageView> views;

 /**
  * @param context
  * @param list
  */
 public GAdapter(Context context, List<SiteStaff> list) {
  mContext = context;
  mListAppInfo = list;  
 }

 @Override
 public int getCount() {
  return mListAppInfo.size();
 }

 @Override
 public Object getItem(int position) {
  return mListAppInfo.get(position);
 }

 @Override
 public long getItemId(int position) {
  return position; …
Run Code Online (Sandbox Code Playgroud)

android android-gridview android-asynctask

5
推荐指数
1
解决办法
5993
查看次数

Android检测到在GridView中的按钮上悬停

我有带有6个按钮的GridView,当用户到达特定按钮的边缘时,我需要检测当前用户的哪个按钮用手指振动.是否可以在GridView的按钮层以某种方式进行,或者更好地在我的gridview中实现它并计算每个按钮边缘的坐标?

android hover android-gridview

5
推荐指数
1
解决办法
943
查看次数

Android GridView中的不同行高或等效

有没有办法在我的应用程序中实现以下功能?应该有一个类似行为的Gridview,但具有不同的行高.还是有另一个wigdet,提供这样的功能?(适配器,n列等)我花了最近3天尝试和捕捉,但我没有得到任何匹配的解决方案

通缉行为

android android-layout android-gridview

5
推荐指数
1
解决办法
1413
查看次数

使用android中的alertbox弹出窗口从gridview更新数据库

我正在使用Android中的网格视图为商店开发客户详细信息.我使用我的数据库获取了客户的详细信息.我需要使用警报框更新客户处理的股票,以便在执行交易时输入库存数量.

customergrid.xml

  <?xml version="1.0" encoding="utf-8"?>

  <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:id="@+id/tab1"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:orientation="vertical" >

      <GridView
          android:id="@+id/grid"
          android:layout_width="fill_parent"
          android:layout_height="357dp"
          android:numColumns="1"
          android:stretchMode="columnWidth" />

      <Button
          android:id="@+id/cancel"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="cancel" />

  </LinearLayout>
Run Code Online (Sandbox Code Playgroud)

并且,对于每一行,我使用了自定义的Xml文件..

customerrow.xml

 <?xml version="1.0" encoding="utf-8"?>
 <TableLayout  xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="fill_parent"
     android:layout_height="fill_parent" >
     <TableRow>
         <TextView
             android:layout_width="50px"
             android:layout_height="wrap_content"
             android:id="@+id/row_ID"
             android:padding="5px"
             android:layout_weight="1" />
         <TextView 
             android:layout_width="50px"
             android:layout_height="wrap_content"
             android:id="@+id/key_ID"
             android:padding="5px"
             android:layout_weight="1" />
         <TextView 
             android:layout_width="50px"
             android:layout_height="wrap_content"
             android:id="@+id/key_Description"
             android:padding="5px"
             android:layout_weight="1" />
     </TableRow>
 </TableLayout>
Run Code Online (Sandbox Code Playgroud)

我在Oncreate()方法上使用了customergrid.xml,并在Grid创建中使用customerrow.xml,如下面的代码所示.

 public void FillGrid() {
     DatabaseHelper sqdb = new DatabaseHelper(this);
     sqdb.openDataBase();
     Cursor cursor;
     GridView grid = (GridView) findViewById(R.id.grvData);
     cursor = …
Run Code Online (Sandbox Code Playgroud)

android android-gridview android-alertdialog

5
推荐指数
1
解决办法
525
查看次数

GridView.setItemChecked(position,value)

我想在左(主)侧使用带有GridView的Master-Detail-Flow.根据文档,GridView有一个setItemChecked(position, value)在API级别1中添加的方法.然而,Eclipse声明该方法需要API级别11.

哪一个是真的?如果我想在GridView中检查项目,我是否需要实现逻辑(带有后台更改等)myelf?

android android-gridview

5
推荐指数
1
解决办法
1176
查看次数

自动滚动AdapterView(Listview,GridView,...)

背景

我正在尝试使用AdapterView(listview,gridview,...)来慢慢自动滚动.

用户可以随时切换它,并且不必一直移动到adapterView的末尾.

再次,我不希望让adapterView一直滚动到底部,因为用户应该可以取消自动滚动.

我试过的

为此,我正在使用下一个代码:

private static final SCROLLING_RUNNABLE = new Runnable() {

    @Override
    public void run() {
        final int duration = 10;
        final int pixelsToMove = 1;
        mAdapterView.smoothScrollBy(pixelsToMove, duration);
        mHandler.postDelayed(this, duration);
    }
};

...
// use this to turn auto-scrolling on:
mHandler.post(SCROLLING_RUNNABLE);
// use this to turn auto-scrolling off:
mHandler.removeCallbacks(SCROLLING_RUNNABLE);
Run Code Online (Sandbox Code Playgroud)

问题

代码通常有效,但在某些情况下,滚动开始需要很长时间.

事实上,似乎我越是开启和关闭,我就越需要等待它开始自动滚动.

我认为只有当我滚动回到顶部时才会出现此问题.当adapterView稍微滚动时,它工作得很好.

因为我无法找到如何获取adapterView的当前滚动值,我无法找到如何解决此问题.

这个问题

我该怎么做才能解决这个问题?还有其他选择吗?

android scroll android-listview android-gridview android-adapterview

5
推荐指数
1
解决办法
3350
查看次数

在android中的gridview中重叠的图像

我正在创建gridview来显示图像.即使我设置垂直和水平间距,静止图像也会相互重叠.为什么会这样?以及如何解决这个问题?你可以在图像中看到这一点.

我的代码:

public class Images extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.images);

        GridView gridView = (GridView) findViewById(R.id.grid_view);
        gridView.setAdapter(new ImageAdapter(this));
        gridView.setOnItemClickListener(new OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View v, int position, long id) { 
                Intent i = new Intent(getApplicationContext(), FullImageActivity.class);
                i.putExtra("id", position);
                startActivity(i);
            }
        });
    }

    public class ImageAdapter extends BaseAdapter {

        private Context mContext; 
        int width, height;

        public Integer[] mThumbIds = {
                R.drawable.radhe, R.drawable.radhe,
                R.drawable.radhe, R.drawable.radhe,
                R.drawable.radhe, R.drawable.radhe,
                R.drawable.radhe, R.drawable.radhe,
                R.drawable.radhe
        };

        // Constructor
        public …
Run Code Online (Sandbox Code Playgroud)

android android-gridview

5
推荐指数
1
解决办法
3060
查看次数

具有3行3列的Android网格视图

我无法设置否。网格视图的行数。只能设置编号。列。

我需要创建一个具有3行3列的网格视图。

谁能帮我一下。

这是我的XML布局代码:

<GridView android:id="@+id/gridView" 
   android:layout_width="match_parent" 
   android:layout_height="match_parent" 
   android:numColumns="3" 
   android:gravity="center" 
   android:stretchMode="columnWidth" > 
</GridView>
Run Code Online (Sandbox Code Playgroud)

在此先感谢Deepak

android android-gridview

5
推荐指数
1
解决办法
1万
查看次数

使用推送通知IntentService中的GoogleApiClient将数据发送到Android Wear

这是一个跟进问题... Android Wear捆绑通知和背景图像

我想创建一个Android Wear GridViewPager布局,当新的推送通知进入时,它会被创建.

下面是我的代码,当新消息进入时初始化GoogleApiClient连接,然后我可以将数据发送到Wear应用程序,然后创建GridView寻呼机.

我的问题是GoogleApiClient永远不会得到连接.我已成功运行sdk文件夹中的SynchonizedNotifications示例应用程序,因此我知道我的设备和手表已正确配对.

以下是当前代码......

public class GCMIntentService extends IntentService implements GoogleApiClient.ConnectionCallbacks,
    GoogleApiClient.OnConnectionFailedListener{

    @Override
    protected void onHandleIntent(Context context, Intent intent) {

        mGoogleApiClient = new GoogleApiClient.Builder(this)
            .addApi(Wearable.API)
            .addConnectionCallbacks(this)
            .addOnConnectionFailedListener(this)
            .build();

        ConnectionResult connectionResult =   mGoogleApiClient.blockingConnect(30, TimeUnit.SECONDS);

        // Extract the payload from the message
        Bundle extras = intent.getExtras();
        if (this.mGoogleApiClient.isConnected())        {

           // sending a simple message works
           MessageApi.SendMessageResult result = Wearable.MessageApi.sendMessage(mGoogleApiClient,
                node.getId(), "path", null).await();

            PutDataMapRequest putDataMapRequest = PutDataMapRequest.create(Constants.BOTH_PATH);
            putDataMapRequest.getDataMap().putString(Constants.KEY_CONTENT, "content");
            putDataMapRequest.getDataMap().putString(Constants.KEY_TITLE, "title");
            PutDataRequest request = putDataMapRequest.asPutDataRequest();

            // push data …
Run Code Online (Sandbox Code Playgroud)

android push-notification android-gridview wear-os

5
推荐指数
2
解决办法
2725
查看次数

如何在Gridview中添加CardView

我找不到合适的解决方案.我想要的是在每个单元格中使用CardView渲染GridView.出于某种原因,我收到此错误:片段类上的java.lang.NullPointerException,在显示gridView.setAdapter(adapter)的行上; 有人可以解释一下是什么问题,我该如何解决?

活动

public class VoteActivity extends Activity {

    private static final String CLASS_TAG = "VoteActivity";


    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        // TODO Auto-generated method stub
        Log.e("CLASS_TAG", CLASS_TAG);
        setContentView(R.layout.activity_vote);

        if (savedInstanceState == null) {
            VoteFragment voteFragment = new VoteFragment();
            voteFragment.setArguments(getIntent().getExtras());
            getFragmentManager().beginTransaction().add(android.R.id.content, voteFragment).commit();
        }


    }

}
Run Code Online (Sandbox Code Playgroud)

分段

public class VoteFragment extends Fragment  {

    VoteAdapter adapter;
    GridView gridView;

    public VoteFragment() {
        // Required empty public constructor
    }

    @Override …
Run Code Online (Sandbox Code Playgroud)

java android adapter android-gridview cardview

5
推荐指数
0
解决办法
3860
查看次数