Alright , heres the code
Heres Java file
public class MainActivity extends Activity implements OnClickListener {
private String array1;
private String [] arraymain;
TextView tv1,tv2;
Button btn;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
if (savedInstanceState == null) {
//getFragmentManager().beginTransaction()
// .add(R.id.container, new PlaceholderFragment()).commit();
}
tv1=(TextView)findViewById(R.id.maintv1);
tv2=(TextView)findViewById(R.id.maintv2);
btn=(Button)findViewById(R.id.mainbutton1);
btn.setOnClickListener(this);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
/**
* A placeholder fragment containing a simple view.
*/
public static class PlaceholderFragment extends Fragment {
public PlaceholderFragment() {
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_main, container,
false);
return rootView;
}
}
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
}
}
and heres the activity_main.xml
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<TextView
android:id="@+id/maintv1"
android:layout_width="50dp"
android:layout_height="50dp"
android:text="Text here"
android:textSize="24dp"
/>
<TextView
android:id="@+id/maintv2"
android:layout_width="50dp"
android:layout_height="50dp"
android:text="Text here"
android:textSize="24dp"
/>
<Button
android:id="@+id/mainbutton1"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:text="Click here"
/>
</LinearLayout>
heres string.xml . the array contains key value pairs.
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">KeyValuePairDemo</string>
<string name="hello_world">Hello world!</string>
<string name="action_settings">Settings</string>
<string-array name="array1" >
<item name="a1">Hello</item>
<item name="a2">Hola</item>
<item name="a2">Helios</item>
</string-array>
</resources>
and heres the image .

Now, what I need to do is, When I click on the Button, It will cycle through array key-value pairs defined in strings.xml and will display key in textview1 and corresponding value in textview2.
If you know how to do it, please paste code here. Or may be give me instructions.
Thanks in advance