class MyAdapter extends BaseAdapter
{
private List<Bean> list = new ArrayList<Bean>();
private LayoutInflater inflater;
public MyAdapter(Context context)
{
list = new ArrayList<Bean>();
inflater = LayoutInflater.from(context);
}
public int getCount()
{
return list.size();
}
public List<Bean> getTaskList()
{
return list;
}
public Object getItem(int position)
{
return list.get(position);
}
public long getItemId(int position)
{
return position;
}
public View getView(int position, View convertView, ViewGroup parent)
{
Bean task = list.get(position);
if (task == null)
{
return convertView;
}
if (convertView == null)
{
convertView = inflater.inflate(R.layout.task_history_row, null);
}
TextView top = (TextView)convertView.findViewById(R.id.task_row_top);
TextView bottom = (TextView)convertView.findViewById(R.id.task_row_bottom);
top.setText(task.getA());
bottom.setText(task.getB());
convertView.setId(position);
return convertView;
}
public void setCTaskData(List<Bean> tList)
{
this.list = tList;
}
}
abstract class MyActivity extends BaseActivity
{
protected View prePressed;
protected List<View> tabList;
private ListView mListView;
private HorizontalScrollView mScroll;
private ImageView line;
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.task_history_main);
initView();
}
protected void onResume()
{
super.onResume();
}
protected void setListAdapter(BaseAdapter adapter)
{
mListView.setAdapter(adapter);
mListView.setOnLongClickListener(this);
}
protected Adapter getListAdapter()
{
return mListView.getAdapter();
}
private void initView()
{
mListView = (ListView)findViewById(R.id.task_list_view);
line = (ImageView)findViewById(R.id.line);
mScroll = (HorizontalScrollView)findViewById(R.id.tabHost);
}
private void initTab(String[] tabArray, OnClickListener listener)
{
LinearLayout.LayoutParams lp =
new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
TabHost host = new TabHost(this, lp, tabArray, listener);
host.setOrientation(LinearLayout.HORIZONTAL);
tabList = host.getTabList();
mScroll.addView(host);
}
public void builder(String[] tabArray, OnClickListener listener)
{
initTab(tabArray, listener);
changeTabView(tabList);
if (tabArray == null || tabArray.length == 0)
{
line.setVisibility(ImageView.GONE);
}
else
{
line.setVisibility(ImageView.VISIBLE);
}
}
private void changeTabView(List<View> mTabList)
{
if (mTabList != null)
{
for (View tabView : mTabList)
{
tabView.setBackgroundResource(R.drawable.tab_unpressed);
}
}
}
public void setPressedTab(View v, int pressed, int unpressed)
{
if (tabList == null)
{
return;
}
if (prePressed != null)
{
prePressed.setBackgroundResource(unpressed);
}
v.setBackgroundResource(pressed);
prePressed = v;
}
public ListView getListView()
{
return mListView;
}
}
{
private List<Bean> list = new ArrayList<Bean>();
private LayoutInflater inflater;
public MyAdapter(Context context)
{
list = new ArrayList<Bean>();
inflater = LayoutInflater.from(context);
}
public int getCount()
{
return list.size();
}
public List<Bean> getTaskList()
{
return list;
}
public Object getItem(int position)
{
return list.get(position);
}
public long getItemId(int position)
{
return position;
}
public View getView(int position, View convertView, ViewGroup parent)
{
Bean task = list.get(position);
if (task == null)
{
return convertView;
}
if (convertView == null)
{
convertView = inflater.inflate(R.layout.task_history_row, null);
}
TextView top = (TextView)convertView.findViewById(R.id.task_row_top);
TextView bottom = (TextView)convertView.findViewById(R.id.task_row_bottom);
top.setText(task.getA());
bottom.setText(task.getB());
convertView.setId(position);
return convertView;
}
public void setCTaskData(List<Bean> tList)
{
this.list = tList;
}
}
abstract class MyActivity extends BaseActivity
{
protected View prePressed;
protected List<View> tabList;
private ListView mListView;
private HorizontalScrollView mScroll;
private ImageView line;
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.task_history_main);
initView();
}
protected void onResume()
{
super.onResume();
}
protected void setListAdapter(BaseAdapter adapter)
{
mListView.setAdapter(adapter);
mListView.setOnLongClickListener(this);
}
protected Adapter getListAdapter()
{
return mListView.getAdapter();
}
private void initView()
{
mListView = (ListView)findViewById(R.id.task_list_view);
line = (ImageView)findViewById(R.id.line);
mScroll = (HorizontalScrollView)findViewById(R.id.tabHost);
}
private void initTab(String[] tabArray, OnClickListener listener)
{
LinearLayout.LayoutParams lp =
new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
TabHost host = new TabHost(this, lp, tabArray, listener);
host.setOrientation(LinearLayout.HORIZONTAL);
tabList = host.getTabList();
mScroll.addView(host);
}
public void builder(String[] tabArray, OnClickListener listener)
{
initTab(tabArray, listener);
changeTabView(tabList);
if (tabArray == null || tabArray.length == 0)
{
line.setVisibility(ImageView.GONE);
}
else
{
line.setVisibility(ImageView.VISIBLE);
}
}
private void changeTabView(List<View> mTabList)
{
if (mTabList != null)
{
for (View tabView : mTabList)
{
tabView.setBackgroundResource(R.drawable.tab_unpressed);
}
}
}
public void setPressedTab(View v, int pressed, int unpressed)
{
if (tabList == null)
{
return;
}
if (prePressed != null)
{
prePressed.setBackgroundResource(unpressed);
}
v.setBackgroundResource(pressed);
prePressed = v;
}
public ListView getListView()
{
return mListView;
}
}