use of android.widget.AdapterView in project AndroidSwipeLayout by daimajia.
the class GridViewExample method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.gridview);
final GridView gridView = (GridView) findViewById(R.id.gridview);
final GridViewAdapter adapter = new GridViewAdapter(this);
adapter.setMode(Attributes.Mode.Multiple);
gridView.setAdapter(adapter);
gridView.setSelected(false);
gridView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
Log.e("onItemLongClick", "onItemLongClick:" + position);
return false;
}
});
gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Log.e("onItemClick", "onItemClick:" + position);
}
});
gridView.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
Log.e("onItemSelected", "onItemSelected:" + position);
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
}
use of android.widget.AdapterView in project AndroidSwipeLayout by daimajia.
the class ListViewExample method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.listview);
mListView = (ListView) findViewById(R.id.listview);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
ActionBar actionBar = getActionBar();
if (actionBar != null) {
actionBar.setTitle("ListView");
}
}
/**
* The following comment is the sample usage of ArraySwipeAdapter.
*/
// String[] adapterData = new String[]{"Activity", "Service", "Content Provider", "Intent", "BroadcastReceiver", "ADT", "Sqlite3", "HttpClient",
// "DDMS", "Android Studio", "Fragment", "Loader", "Activity", "Service", "Content Provider", "Intent",
// "BroadcastReceiver", "ADT", "Sqlite3", "HttpClient", "Activity", "Service", "Content Provider", "Intent",
// "BroadcastReceiver", "ADT", "Sqlite3", "HttpClient"};
// mListView.setAdapter(new ArraySwipeAdapterSample<String>(this, R.layout.listview_item, R.id.position, adapterData));
mAdapter = new ListViewAdapter(this);
mListView.setAdapter(mAdapter);
mAdapter.setMode(Attributes.Mode.Single);
mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
((SwipeLayout) (mListView.getChildAt(position - mListView.getFirstVisiblePosition()))).open(true);
}
});
mListView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
Log.e("ListView", "OnTouch");
return false;
}
});
mListView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
Toast.makeText(mContext, "OnItemLongClickListener", Toast.LENGTH_SHORT).show();
return true;
}
});
mListView.setOnScrollListener(new AbsListView.OnScrollListener() {
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
Log.e("ListView", "onScrollStateChanged");
}
@Override
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
}
});
mListView.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
Log.e("ListView", "onItemSelected:" + position);
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
Log.e("ListView", "onNothingSelected:");
}
});
}
use of android.widget.AdapterView in project AndroidViewAnimations by daimajia.
the class MyActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_my);
mListView = (ListView) findViewById(R.id.list_items);
mTarget = findViewById(R.id.hello_world);
mAdapter = new EffectAdapter(this);
mListView.setAdapter(mAdapter);
mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
if (rope != null) {
rope.stop(true);
}
Techniques technique = (Techniques) view.getTag();
rope = YoYo.with(technique).duration(1200).repeat(YoYo.INFINITE).pivot(YoYo.CENTER_PIVOT, YoYo.CENTER_PIVOT).interpolate(new AccelerateDecelerateInterpolator()).withListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
}
@Override
public void onAnimationEnd(Animator animation) {
}
@Override
public void onAnimationCancel(Animator animation) {
Toast.makeText(MyActivity.this, "canceled previous animation", Toast.LENGTH_SHORT).show();
}
@Override
public void onAnimationRepeat(Animator animation) {
}
}).playOn(mTarget);
}
});
findViewById(R.id.hello_world).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (rope != null) {
rope.stop(true);
}
}
});
}
use of android.widget.AdapterView in project UltimateAndroid by cymcsg.
the class SuperListViewActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.super_list_view_activity_main);
ArrayList<String> lst = new ArrayList<String>();
lst.add("List example");
lst.add("Grid example");
mAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, android.R.id.text1, lst);
mList = (SuperListview) findViewById(R.id.list);
mList.setAdapter(mAdapter);
mList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Intent i = new Intent();
switch(position) {
case 0:
i.setClass(SuperListViewActivity.this, ListSample.class);
break;
case 1:
i.setClass(SuperListViewActivity.this, GridSample.class);
}
startActivity(i);
}
});
}
use of android.widget.AdapterView in project UltimateAndroid by cymcsg.
the class SwipeLayout method isEnabledInAdapterView.
/**
* if working in {@link android.widget.AdapterView}, we should response {@link android.widget.Adapter}
* isEnable(int position).
* @return true when item is enabled, else disabled.
*/
private boolean isEnabledInAdapterView() {
AdapterView adapterView = getAdapterView();
boolean enable = true;
if (adapterView != null) {
Adapter adapter = adapterView.getAdapter();
if (adapter != null) {
int p = adapterView.getPositionForView(SwipeLayout.this);
if (adapter instanceof BaseAdapter) {
enable = ((BaseAdapter) adapter).isEnabled(p);
} else if (adapter instanceof ListAdapter) {
enable = ((ListAdapter) adapter).isEnabled(p);
}
}
}
return enable;
}
Aggregations