本文整理匯總了Java中android.widget.ListView.setOnTouchListener方法的典型用法代碼示例。如果您正苦於以下問題:Java ListView.setOnTouchListener方法的具體用法?Java ListView.setOnTouchListener怎麽用?Java ListView.setOnTouchListener使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.widget.ListView
的用法示例。
在下文中一共展示了ListView.setOnTouchListener方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: viewInitialize
import android.widget.ListView; //導入方法依賴的package包/類
public void viewInitialize()
{
mainListView = (ListView) findViewById(R.id.listview);
scrollview = (NestedScrollView) findViewById(R.id.scrollview);
mainListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
Log.e("PlayListFragment", i+"/"+l);
global.playMusic(Integer.parseInt(playList.get(i)));
}
});
mainListView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event)
{
scrollview.requestDisallowInterceptTouchEvent(true);
return false;
}
});
}
示例2: onCreate
import android.widget.ListView; //導入方法依賴的package包/類
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
PrefStore.setLocale(this);
setContentView(R.layout.activity_profiles);
// ListView Adapter
listView = (ListView) findViewById(R.id.profilesView);
adapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_single_choice, listItems);
listView.setAdapter(adapter);
// Initialize the Gesture Detector
listView.setOnTouchListener(this);
gd = new GestureDetector(this,
new GestureDetector.SimpleOnGestureListener() {
@Override
public boolean onDoubleTap(MotionEvent e) {
finish();
return false;
}
});
}
示例3: QsDetailItemsList
import android.widget.ListView; //導入方法依賴的package包/類
private QsDetailItemsList(LinearLayout view) {
mView = view;
mListView = (ListView) mView.findViewById(android.R.id.list);
mListView.setOnTouchListener(new OnTouchListener() {
// Setting on Touch Listener for handling the touch inside ScrollView
@Override
public boolean onTouch(View v, MotionEvent event) {
// Disallow the touch request for parent scroll on touch of child view
v.getParent().requestDisallowInterceptTouchEvent(true);
return false;
}
});
mEmpty = mView.findViewById(android.R.id.empty);
mEmpty.setVisibility(View.GONE);
mEmptyText = (TextView) mEmpty.findViewById(android.R.id.title);
mEmptyIcon = (ImageView) mEmpty.findViewById(android.R.id.icon);
mListView.setEmptyView(mEmpty);
}
示例4: ListViewRefresh
import android.widget.ListView; //導入方法依賴的package包/類
public ListViewRefresh(ListView listView) {
this.listView = listView;
listView.setOnTouchListener(this);
}
示例5: rearranging
import android.widget.ListView; //導入方法依賴的package包/類
public void rearranging() {
mListView = (ListView) findViewById(R.id.listrearr);
mAdapter = new MyArrayAdapter(this, R.layout.row_string);
mListView.setAdapter(mAdapter);
mListView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent event) {
if (!mSortable) {
return false;
}
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN: {
break;
}
case MotionEvent.ACTION_MOVE: {
int position = mListView.pointToPosition((int) event.getX(), (int) event.getY());
if (position < 0) {
break;
}
if (position != mPosition) {
mPosition = position;
mAdapter.remove(mDragString);
mAdapter.insert(mDragString, mPosition);
}
return true;
}
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_CANCEL:
case MotionEvent.ACTION_OUTSIDE: {
stopDrag();
return true;
}
}
return false;
}
});
DatabaseHandler db1 = new DatabaseHandler(this);
List<Contact> contacts1 = db1.getAllContacts();
}
示例6: onCreate
import android.widget.ListView; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ArrayList<String> arData = new ArrayList<String>();
mAdapter = new ArrayAdapter<String>(this, R.layout.support_simple_spinner_dropdown_item, arData);
ListView list = (ListView)findViewById(R.id.logList);
mAdapter.add("ssss");
list.setAdapter(mAdapter);
try {
FileInputStream fis = openFileInput("MousePos.txt");
FileChannel inChannel = fis.getChannel();
final int s = fis.available();
ByteBuffer buff = ByteBuffer.allocate((int)fis.available());
buff.clear();
inChannel.read(buff);
buff.rewind();
final int posSize = s/4;
float[] pos = new float[posSize];
buff.asFloatBuffer().get(pos);
inChannel.close();
for (int i=0; i < posSize; i+=2)
{
mAdapter.add("" + pos[i] + ", " + pos[i+1]);
}
fis.close();
} catch (Exception e) {
System.err.println(e.getMessage());
}
list.setOnTouchListener(this);
}