getView()
ofCursorAdapter
にはパラメーターがあるので、そのposition
チェックを行うことposition
がbindView()
できposition
ますBindView
。
現在、私は をオーバーライドしていますnewView()
が、私が読んだり聞いたりしたのは悪いもので、ORと をオーバーライドします。bindView()
getView()
getView()
newView()
getView()
ありがとう。
getView()
ofCursorAdapter
にはパラメーターがあるので、そのposition
チェックを行うことposition
がbindView()
できposition
ますBindView
。
現在、私は をオーバーライドしていますnewView()
が、私が読んだり聞いたりしたのは悪いもので、ORと をオーバーライドします。bindView()
getView()
getView()
newView()
getView()
ありがとう。
これを試して
public void bindView(View arg0, Context arg1, Cursor arg2)
{
int pos = arg2.getPosition();
}
codeboys の答えは正しいです。cursor.getPosition() で十分です。しかし、誰かが listitems サブアイテムの onClick イベントで位置を必要とする場合、たとえば listItem 内のアイコンの場合、解決策はアイコンに setTag として位置を配置し、イベントが発生したときにそれを取得することです。
@Override
public void bindView(View vw, Context ctx, final Cursor cursor) {
/* ...
* do your binding
*/
ImageView icon = (ImageView) vw.findViewById(R.id.your_icon);
icon.setTag(cursor.getPosition()); // here you set position on a tag
icon.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// use a tag to get the right position
((MainActivity) context).onIconClick((int)v.getTag());
}
});
}
@Override
public void bindView(View view, Context context, Cursor cursor) {
// TODO Auto-generated method stub
}
@Override
public View newView(Context context, Cursor cursor, ViewGroup view) {
// TODO Auto-generated method stub
int mCount = cursor.getCount();
//Returns Total count(Rows) in cursor
int currentPostion= cursor.getPosition();
//Returns the current position of the cursor in the row set
}