In my application I am displaying list view with image and text in that i added one button called read more if i click the read more button i want to move to next activity.
can any one please help.
OurTeam class
public class OurTeam extends Activity {
Button click;
// Array of strings storing country names
String[] countries = new String[] {
"Arun Arora Chairman, Edvance Group",
"Anshul Arora CEO, Edvance Group ",
"Ranjan Goyal CEO, Edvance Pre-Schools "
};
// Array of integers points to images stored in /res/drawable-ldpi/
int[] flags = new int[]{
R.drawable.arun_arora_chairman,
R.drawable.anshul_arora_ceo,
R.drawable.ranjan_goyal_ceo
};
// Array of strings to store currencies
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.ourteam1);
click = (Button)findViewById(R.id.click);
//click.setBackgroundColor(Color.TRANSPARENT);
/*click.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
//click.setVisibility(View.INVISIBLE);
//rl.setBackgroundResource(R.drawable.voted);
//mp.start();
Intent in = new Intent(getApplicationContext(), AboutUs.class);
startActivity(in);
//text.setText("Thanks for Voting S K Vel Election Date is on 24th April 2014. Please come and vote for your S K Vel. Our Party Symbol is Drum.");
//text.setVisibility(View.VISIBLE);
}
}); */
// Each row in the list stores country name, currency and flag
List<HashMap<String,String>> aList = new ArrayList<HashMap<String,String>>();
for(int i=0;i<3;i++){
HashMap<String, String> hm = new HashMap<String,String>();
hm.put("txt", countries[i]);
hm.put("flag", Integer.toString(flags[i]) );
aList.add(hm);
}
// Keys used in Hashmap
String[] from = { "flag","txt"};
// Ids of views in listview_layout
int[] to = { R.id.flag,R.id.txt};
// Instantiating an adapter to store each items
// R.layout.listview_layout defines the layout of each item
SimpleAdapter adapter = new SimpleAdapter(getBaseContext(), aList, R.layout.ourteam, from, to);
// Getting a reference to listview of main.xml layout file
final ListView listView = ( ListView ) findViewById(R.id.listview);
// Setting the adapter to the listView
listView.setAdapter(adapter);
listView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1,
int position, long arg3) {
switch (position) {
case R.id.click:
Intent in = new Intent(getApplicationContext(), AboutUs.class);
startActivity(in);
break;
}
}
});
}
}
ourteam.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:background="@drawable/layout_bg"
>
<ImageView
android:id="@+id/flag"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/hello"
android:paddingTop="10dp"
android:paddingRight="10dp"
android:paddingBottom="10dp"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<TextView
android:id="@+id/txt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#000000"
android:textSize="16sp"
android:textStyle="bold"
/>
<Button
android:id="@+id/click"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:text="Read More" />
</LinearLayout>
</LinearLayout>
ourteam1.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<ListView
android:id="@+id/listview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:divider="@android:color/transparent"
android:dividerHeight="10.0sp"
/>
</LinearLayout>