package com.mmad.hotelappmaroon;
import java.util.ArrayList;
import android.os.Bundle;
import android.app.Activity;
import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
public class PageActivity extends Activity {
ArrayList<TajGuide> tajGuideList;
ListView listViewPage;
TajGuideAdapter tajGuideAdapter;
ImageButton title_image;
TYPE type;
public enum TYPE{
Television,
Movies,
Music,
Internet,
TajGuide,
Games,
Tools,
Connect
}
Bundle pageActivityBundle;
String valueType;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
initVar();
pageActivityBundle=getIntent().getExtras();
valueType=pageActivityBundle.getString("TYPE");
getSwirchType(valueType);
Log.d("button type", valueType);
Toast.makeText(getApplicationContext(), "****Clicked********"+valueType, 500).show();
}
private void initVar() {
TajGuide tj ;
tajGuideList = new ArrayList<TajGuide>();
listViewPage=(ListView)findViewById(R.id.listViewPage);
tj = new TajGuide(1, "Restaurant");
tajGuideList.add(tj);
tj = new TajGuide(1, "Restaurant");
tajGuideList.add(tj);
tj = new TajGuide(1, "Restaurant");
tajGuideList.add(tj);
tj = new TajGuide(1, "Restaurant");
tajGuideList.add(tj);
tj = new TajGuide(1, "Restaurant");
tajGuideList.add(tj);
tj = new TajGuide(1, "Restaurant");
tajGuideList.add(tj);
tj = new TajGuide(1, "Restaurant");
tajGuideList.add(tj);
tj = new TajGuide(1, "Restaurant");
tajGuideList.add(tj);
tj = new TajGuide(1, "Restaurant");
tajGuideList.add(tj);
tj = new TajGuide(1, "Restaurant");
tajGuideList.add(tj);
tj = new TajGuide(1, "Restaurant");
tajGuideList.add(tj);
tj = new TajGuide(1, "Restaurant");
tajGuideList.add(tj);
tj = new TajGuide(1, "Restaurant");
tajGuideList.add(tj);
tj = new TajGuide(1, "Restaurant");
tajGuideList.add(tj);
tj = new TajGuide(1, "Restaurant");
tajGuideList.add(tj);
tj = new TajGuide(1, "Restaurant");
tajGuideList.add(tj);
tj = new TajGuide(1, "Restaurant");
tajGuideList.add(tj);
}
private void fillGuideAdapter() {
//layout_display.setVisibility(View.GONE);
tajGuideAdapter = new TajGuideAdapter(getApplicationContext());
listViewPage.setAdapter(tajGuideAdapter);
tajGuideAdapter.setNotifyOnChange(true);
tajGuideAdapter.notifyDataSetChanged();
}
private void getSwirchType(String value){
switch (type.valueOf(valueType)) {
case Television:
Toast.makeText(getApplicationContext(), "************"+valueType, 500).show();
break;
case Movies:
Toast.makeText(getApplicationContext(), "************"+valueType, 500).show();
break;
case TajGuide:
fillGuideAdapter();
Toast.makeText(getApplicationContext(), "************"+valueType, 500).show();
break;
default:
break;
}
}
public class TajGuideAdapter extends ArrayAdapter {
Context context;
public TajGuideAdapter(Context context) {
super(context, R.layout.item_guide_list,tajGuideList);
this.context = context;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
final ViewHolder holder;
if(convertView == null) {
convertView = (LinearLayout)LayoutInflater.from(context).inflate(R.layout.item_guide_list, null);
holder = new ViewHolder();
holder.imageView=(ImageView)convertView.findViewById(R.id.guide_image);
holder.textViewHeadingValue=(TextView)convertView.findViewById(R.id.guide_Title);
listViewPage.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View v,
int position, long id) {
String value=parent.getItemAtPosition(position).toString();
// When clicked, show a toast with the TextView text
Toast.makeText(getApplicationContext(), "*********hai", 500).show();
Log.d("", "********************************");
}
});
convertView.setTag(holder);
}else{
holder = (ViewHolder) convertView.getTag();
}
//holder.imageView.setBackgroundResource(tajGuideList.get(position).getImage());
holder.textViewHeadingValue.setText(tajGuideList.get(position).getTitle());
return convertView;
}
}
public class ViewHolder {
TextView textView,textViewHeading,textViewHeadingValue,textViewDay,textViewWind,textViewHumidity,textViewSunrise;
ImageView imageView,imageViewWeather;
}
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
}
import java.util.ArrayList;
import android.os.Bundle;
import android.app.Activity;
import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
public class PageActivity extends Activity {
ArrayList<TajGuide> tajGuideList;
ListView listViewPage;
TajGuideAdapter tajGuideAdapter;
ImageButton title_image;
TYPE type;
public enum TYPE{
Television,
Movies,
Music,
Internet,
TajGuide,
Games,
Tools,
Connect
}
Bundle pageActivityBundle;
String valueType;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
initVar();
pageActivityBundle=getIntent().getExtras();
valueType=pageActivityBundle.getString("TYPE");
getSwirchType(valueType);
Log.d("button type", valueType);
Toast.makeText(getApplicationContext(), "****Clicked********"+valueType, 500).show();
}
private void initVar() {
TajGuide tj ;
tajGuideList = new ArrayList<TajGuide>();
listViewPage=(ListView)findViewById(R.id.listViewPage);
tj = new TajGuide(1, "Restaurant");
tajGuideList.add(tj);
tj = new TajGuide(1, "Restaurant");
tajGuideList.add(tj);
tj = new TajGuide(1, "Restaurant");
tajGuideList.add(tj);
tj = new TajGuide(1, "Restaurant");
tajGuideList.add(tj);
tj = new TajGuide(1, "Restaurant");
tajGuideList.add(tj);
tj = new TajGuide(1, "Restaurant");
tajGuideList.add(tj);
tj = new TajGuide(1, "Restaurant");
tajGuideList.add(tj);
tj = new TajGuide(1, "Restaurant");
tajGuideList.add(tj);
tj = new TajGuide(1, "Restaurant");
tajGuideList.add(tj);
tj = new TajGuide(1, "Restaurant");
tajGuideList.add(tj);
tj = new TajGuide(1, "Restaurant");
tajGuideList.add(tj);
tj = new TajGuide(1, "Restaurant");
tajGuideList.add(tj);
tj = new TajGuide(1, "Restaurant");
tajGuideList.add(tj);
tj = new TajGuide(1, "Restaurant");
tajGuideList.add(tj);
tj = new TajGuide(1, "Restaurant");
tajGuideList.add(tj);
tj = new TajGuide(1, "Restaurant");
tajGuideList.add(tj);
tj = new TajGuide(1, "Restaurant");
tajGuideList.add(tj);
}
private void fillGuideAdapter() {
//layout_display.setVisibility(View.GONE);
tajGuideAdapter = new TajGuideAdapter(getApplicationContext());
listViewPage.setAdapter(tajGuideAdapter);
tajGuideAdapter.setNotifyOnChange(true);
tajGuideAdapter.notifyDataSetChanged();
}
private void getSwirchType(String value){
switch (type.valueOf(valueType)) {
case Television:
Toast.makeText(getApplicationContext(), "************"+valueType, 500).show();
break;
case Movies:
Toast.makeText(getApplicationContext(), "************"+valueType, 500).show();
break;
case TajGuide:
fillGuideAdapter();
Toast.makeText(getApplicationContext(), "************"+valueType, 500).show();
break;
default:
break;
}
}
public class TajGuideAdapter extends ArrayAdapter {
Context context;
public TajGuideAdapter(Context context) {
super(context, R.layout.item_guide_list,tajGuideList);
this.context = context;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
final ViewHolder holder;
if(convertView == null) {
convertView = (LinearLayout)LayoutInflater.from(context).inflate(R.layout.item_guide_list, null);
holder = new ViewHolder();
holder.imageView=(ImageView)convertView.findViewById(R.id.guide_image);
holder.textViewHeadingValue=(TextView)convertView.findViewById(R.id.guide_Title);
listViewPage.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View v,
int position, long id) {
String value=parent.getItemAtPosition(position).toString();
// When clicked, show a toast with the TextView text
Toast.makeText(getApplicationContext(), "*********hai", 500).show();
Log.d("", "********************************");
}
});
convertView.setTag(holder);
}else{
holder = (ViewHolder) convertView.getTag();
}
//holder.imageView.setBackgroundResource(tajGuideList.get(position).getImage());
holder.textViewHeadingValue.setText(tajGuideList.get(position).getTitle());
return convertView;
}
}
public class ViewHolder {
TextView textView,textViewHeading,textViewHeadingValue,textViewDay,textViewWind,textViewHumidity,textViewSunrise;
ImageView imageView,imageViewWeather;
}
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
}
No comments:
Post a Comment