Hi i am new to android animation..
I want to update my image to new position after animation but i fail to do so will appreciate any kind of help..(I have a basic left to right and right to left animation)
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:background="#drawable/main_menu_background"
android:orientation="vertical" >
<TableRow
android:layout_width="fill_parent"
android:layout_height="20dp"
android:background="#android:color/transparent"
android:weightSum="4" >
<View
android:layout_width="0.5dip"
android:layout_weight="0.18"
android:background="#android:color/transparent" />
<View
android:layout_width="0.5dip"
android:layout_weight="0.65"
android:background="#drawable/main_menu_fill" />
<View
android:layout_width="3dip"
android:layout_weight="3.17"
android:background="#android:color/transparent" />
</TableRow>
<TableRow
android:layout_width="fill_parent"
android:layout_height="60dp" >
<TextView
android:id="#+id/logo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_span="3"
android:background="#drawable/main_menu_fill"
android:padding="10dip"
android:text="My App"
android:textColor="#android:color/white"
android:textSize="34dp"
android:textStyle="bold" />
</TableRow>
<TableRow
android:layout_width="fill_parent"
android:layout_height="100dp"
android:background="#android:color/transparent"
android:weightSum="4" >
<View
android:layout_width="0.5dip"
android:layout_weight="0.18"
android:background="#android:color/transparent" />
<View
android:layout_width="0.5dip"
android:layout_weight="0.65"
android:background="#drawable/main_menu_fill" />
<View
android:layout_width="3dip"
android:layout_weight="3.17"
android:background="#android:color/transparent" />
</TableRow>
<TableRow
android:layout_width="fill_parent"
android:layout_height="55dp"
android:background="#android:color/transparent"
android:weightSum="4" >
<View
android:layout_width="0.5dip"
android:layout_weight="0.18"
android:background="#android:color/transparent" />
<ImageView
android:id="#+id/btn1"
android:layout_width="0.5dip"
android:layout_weight="0.65"
android:background="#drawable/main_menu_fill"
android:src="#drawable/main_menu_button" />
<View
android:layout_width="3dip"
android:layout_weight="3.17"
android:background="#android:color/transparent" />
</TableRow>
<TableRow
android:layout_width="fill_parent"
android:layout_height="55dp"
android:background="#android:color/transparent"
android:weightSum="4" >
<View
android:layout_width="0.5dip"
android:layout_weight="0.18"
android:background="#android:color/transparent" />
<ImageView
android:id="#+id/btn2"
android:layout_width="0.5dip"
android:layout_weight="0.65"
android:background="#drawable/main_menu_fill"
android:src="#drawable/main_menu_button" />
<View
android:layout_width="3dip"
android:layout_weight="3.17"
android:background="#android:color/transparent" />
</TableRow>
<TableRow
android:layout_width="fill_parent"
android:layout_height="55dp"
android:background="#android:color/transparent"
android:weightSum="4" >
<View
android:layout_width="0.5dip"
android:layout_weight="0.18"
android:background="#android:color/transparent" />
<ImageView
android:id="#+id/btn3"
android:layout_width="0.5dip"
android:layout_weight="0.65"
android:background="#drawable/main_menu_fill"
android:src="#drawable/main_menu_button" />
<View
android:layout_width="3dip"
android:layout_weight="3.17"
android:background="#android:color/transparent" />
</TableRow>
<TableRow
android:layout_width="fill_parent"
android:layout_height="55dp"
android:background="#android:color/transparent"
android:weightSum="4" >
<View
android:layout_width="0.5dip"
android:layout_weight="0.18"
android:background="#android:color/transparent" />
<ImageView
android:id="#+id/btn4"
android:layout_width="0.5dip"
android:layout_weight="0.65"
android:background="#drawable/main_menu_fill"
android:src="#drawable/main_menu_button" />
<View
android:layout_width="3dip"
android:layout_weight="3.17"
android:background="#android:color/transparent" />
</TableRow>
<TableRow
android:layout_width="fill_parent"
android:layout_height="55dp"
android:background="#android:color/transparent"
android:weightSum="4" >
<View
android:layout_width="0.5dip"
android:layout_weight="0.18"
android:background="#android:color/transparent" />
<ImageView
android:id="#+id/btn5"
android:layout_width="0.5dip"
android:layout_weight="0.65"
android:background="#drawable/main_menu_fill"
android:src="#drawable/main_menu_button" />
<View
android:layout_width="3dip"
android:layout_weight="3.17"
android:background="#android:color/transparent" />
</TableRow>
<TableRow
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#android:color/transparent"
android:weightSum="4" >
<View
android:layout_width="0.5dip"
android:layout_weight="0.18"
android:background="#android:color/transparent" />
<View
android:layout_width="0.5dip"
android:layout_weight="0.65"
android:background="#drawable/main_menu_fill" />
<View
android:layout_width="3dip"
android:layout_weight="3.17"
android:background="#android:color/transparent" />
</TableRow>
</LinearLayout>
Java:
package com.example.mainmenuscreen;
import android.location.GpsStatus.Listener;
import android.os.Bundle;
import android.app.Activity;
import android.content.Context;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
import android.widget.LinearLayout.LayoutParams;
public class MainScreenActivity extends Activity {
OnClickListener openListener;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main_screen);
Context context = getApplicationContext();
final ImageView login = (ImageView) findViewById(R.id.login);
final Animation lefttoright = AnimationUtils.loadAnimation(context,
R.anim.lefttoright);
Animation righttoleft = AnimationUtils.loadAnimation(context,
R.anim.righttoleft);
// login.startAnimation(righttoleft);
login.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
login.startAnimation(lefttoright);
}
});
lefttoright.setAnimationListener(new Animation.AnimationListener() {
public void onAnimationStart(Animation animation) {
// TODO Auto-generated method stub
}
public void onAnimationRepeat(Animation animation) {
// TODO Auto-generated method stub
}
public void onAnimationEnd(Animation animation) {
android.widget.LinearLayout.LayoutParams params = new LayoutParams(
android.widget.LinearLayout.LayoutParams.FILL_PARENT,
android.widget.LinearLayout.LayoutParams.WRAP_CONTENT);
// params.topMargin = login.getTop()-100;
params.setMargins(0, 0, 100, 0);
login.setLayoutParams(params);
}
});
}
}
have you tried
Animation#setFillAfter
API doc
Related
I'm building an app that sends USSD commands to check for balance, etc.
The apps acts weirdly when I try to launch activities from item click, here from image button: I have to touch two times to launch an activity. I don't know what is wrong.
Have a look at my code:
MainActivity.java:
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.RelativeLayout;
public class MainActivity extends AppCompatActivity {
ImageView accountView;
ImageView activationsView;
ImageView servicesView;
ImageView othersView;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void openAccountView(View view){
accountView = (ImageView) findViewById(R.id.accountView);
accountView.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Intent i = new Intent(MainActivity.this, AccountActivity.class);
startActivity(i);
}
});
}
public void openActivationsView(View view){
activationsView = (ImageView) findViewById(R.id.activationsView);
activationsView.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Intent i = new Intent(MainActivity.this, ActivationsActivity.class);
startActivity(i);
}
});
}
public void openServicesView(View view){
servicesView = (ImageView) findViewById(R.id.servicesView);
servicesView.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Intent i = new Intent(MainActivity.this, ServicesActivity.class);
startActivity(i);
}
});
}
public void openOthersView(View view){
}
}
activity_main.xml:
<?xml version="1.0" encoding="utf-8" ?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="#id/layout_dashboard_parent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#android:color/white">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:background="#color/c_dashboard_btn_quick_clean_color"
android:orientation="horizontal">
<Button
android:id="#+id/buttonCB"
style="#android:style/Widget.Material.Light.Button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="2dip"
android:layout_marginLeft="2dip"
android:layout_marginRight="2dip"
android:layout_weight="2"
android:background="#color/c_main_back_ground_color"
android:elevation="7dp"
android:text="#string/check_balance"
tools:ignore="ButtonStyle"
tools:targetApi="lollipop" />
<Button
android:id="#+id/buttonLB"
style="#android:style/Widget.Material.Button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="2dip"
android:layout_marginRight="2dip"
android:layout_marginStart="2dip"
android:layout_weight="2"
android:background="#color/c_main_back_ground_color"
android:elevation="7dp"
android:text="#string/load_balance"
tools:ignore="ButtonStyle"
tools:targetApi="lollipop" />
</LinearLayout>
<ScrollView
android:id="#id/main_scroll_view"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/webview_ads"
tools:ignore="UnknownIdInLayout">
<LinearLayout
android:id="#id/layout_dashboard_scroll_container"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:weightSum="1">
<FrameLayout
android:id="#id/dashboard_alert_section"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:visibility="gone">
<include layout="#layout/dashboard_feature_tip_item" />
</FrameLayout>
<FrameLayout
android:id="#id/main_control_layout"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="345">
<FrameLayout
android:id="#id/dashboard_progress_bar"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginTop="#dimen/dashboard_clean_progess_mar_top"
android:elevation="#dimen/dashboard_progressbar_elevation"
android:visibility="gone"
tools:ignore="UselessParent"
tools:targetApi="lollipop">
<ImageView
android:layout_width="#dimen/dashboard_progress_clean_all_image_dimension"
android:layout_height="#dimen/dashboard_progress_clean_all_image_dimension"
android:layout_gravity="center"
android:contentDescription=""
android:src="#drawable/btn_ram_checkbox"
tools:ignore="ContentDescription" />
<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center" />
</FrameLayout>
</FrameLayout>
</LinearLayout>
</ScrollView>
<RelativeLayout
android:id="#id/layout_main"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:background="#color/c_main_back_ground_color">
<RelativeLayout
android:id="#id/layout_account"
android:layout_width="#dimen/dashboard_feature_layout_width"
android:layout_height="#dimen/dashboard_feature_layout_height"
android:layout_marginEnd="#dimen/dashboard_feature_middle_margin"
android:layout_marginLeft="#dimen/dashboard_feature_leftmost_margin"
android:layout_marginRight="#dimen/dashboard_feature_middle_margin"
android:layout_marginStart="#dimen/dashboard_feature_leftmost_margin"
android:layout_marginTop="#dimen/dashboard_feature_top_margin"
android:background="#drawable/dashboard_bg_selector"
android:clickable="false"
android:elevation="6dp"
android:focusable="false"
tools:targetApi="lollipop">
<ImageView
android:id="#+id/accountView"
android:layout_width="130dip"
android:layout_height="130dip"
android:layout_alignParentEnd="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:adjustViewBounds="false"
android:background="#color/checkbox_button_color"
android:clickable="true"
android:contentDescription="#string/account"
android:cropToPadding="false"
android:onClick="openAccountView"
android:visibility="visible"
app:srcCompat="#drawable/account" />
<TextView
android:id="#+id/accountTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="14dp"
android:gravity="center_vertical|center_horizontal|center"
android:text="#string/account"
android:textColor="#color/body_text_color"
android:textSize="18sp"
android:textStyle="bold" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/accountView"
android:paddingBottom="2dip"
android:paddingEnd="2dip"
android:paddingLeft="2dip"
android:paddingRight="2dip"
android:paddingStart="2dip"
android:text="#string/account_detail"
android:textAlignment="center"
android:textColor="#color/black"
android:textSize="12sp" />
</RelativeLayout>
<RelativeLayout
android:id="#id/layout_activations"
android:layout_width="#dimen/dashboard_feature_layout_width"
android:layout_height="#dimen/dashboard_feature_layout_height"
android:layout_marginEnd="#dimen/dashboard_feature_rightmost_margin"
android:layout_marginLeft="#dimen/dashboard_feature_middle_margin"
android:layout_marginRight="#dimen/dashboard_feature_rightmost_margin"
android:layout_marginStart="#dimen/dashboard_feature_middle_margin"
android:layout_marginTop="#dimen/dashboard_feature_top_margin"
android:layout_toEndOf="#id/layout_account"
android:layout_toRightOf="#id/layout_account"
android:background="#drawable/dashboard_bg_selector"
android:clickable="false"
android:elevation="#dimen/dashboard_feature_bg_elevation"
android:focusable="false"
android:onClick="openActivationsView"
tools:targetApi="lollipop">
<ImageView
android:id="#+id/activationsView"
android:layout_width="130dip"
android:layout_height="130dip"
android:layout_alignParentEnd="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="false"
android:layout_centerHorizontal="true"
android:layout_centerInParent="true"
android:layout_centerVertical="true"
android:clickable="true"
android:contentDescription="#string/activations_packs"
android:onClick="openActivationsView"
app:srcCompat="#drawable/activations" />
<TextView
android:id="#+id/textView3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/activationsView"
android:elevation="7dp"
android:paddingBottom="2dip"
android:paddingEnd="2dip"
android:paddingLeft="2dip"
android:paddingRight="2dip"
android:paddingStart="2dip"
android:text="#string/activations_detail"
android:textAlignment="center"
android:textColor="#color/black"
android:textSize="12sp" />
<TextView
android:id="#+id/activationsTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="14dp"
android:gravity="center_vertical|center_horizontal|center"
android:text="#string/activations_packs"
android:textAlignment="center"
android:textColor="#color/black"
android:textSize="18sp"
android:textStyle="bold" />
</RelativeLayout>
<RelativeLayout
android:id="#id/layout_services"
android:layout_width="#dimen/dashboard_feature_layout_width"
android:layout_height="#dimen/dashboard_feature_layout_height"
android:layout_below="#id/layout_account"
android:layout_marginBottom="10dip"
android:layout_marginEnd="#dimen/dashboard_feature_middle_margin"
android:layout_marginLeft="#dimen/dashboard_feature_leftmost_margin"
android:layout_marginRight="#dimen/dashboard_feature_middle_margin"
android:layout_marginStart="#dimen/dashboard_feature_leftmost_margin"
android:layout_marginTop="#dimen/dashboard_feature_ram_security_top_margin"
android:background="#drawable/dashboard_bg_selector"
android:clickable="false"
android:elevation="5dp"
android:focusable="false"
android:onClick="openServicesView"
tools:targetApi="lollipop">
<TextView
android:id="#+id/servicesTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="14dp"
android:gravity="center_vertical|center_horizontal|center"
android:text="#string/services"
android:textColor="#android:color/black"
android:textSize="18sp"
android:textStyle="bold" />
<ImageView
android:id="#+id/servicesView"
android:layout_width="130dip"
android:layout_height="130dip"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:contentDescription="#string/services"
app:srcCompat="#drawable/services" />
<TextView
android:id="#+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/servicesView"
android:paddingBottom="2dip"
android:paddingEnd="2dip"
android:paddingLeft="2dip"
android:paddingRight="2dip"
android:paddingStart="2dip"
android:text="#string/services_detail"
android:textAlignment="center"
android:textColor="#color/black"
android:textSize="12sp" />
</RelativeLayout>
<RelativeLayout
android:id="#id/layout_others"
android:layout_width="#dimen/dashboard_feature_layout_width"
android:layout_height="#dimen/dashboard_feature_layout_height"
android:layout_below="#id/layout_activations"
android:layout_marginBottom="10dip"
android:layout_marginEnd="#dimen/dashboard_feature_rightmost_margin"
android:layout_marginLeft="#dimen/dashboard_feature_middle_margin"
android:layout_marginRight="#dimen/dashboard_feature_rightmost_margin"
android:layout_marginStart="#dimen/dashboard_feature_middle_margin"
android:layout_marginTop="#dimen/dashboard_feature_ram_security_top_margin"
android:layout_toEndOf="#id/layout_services"
android:layout_toRightOf="#id/layout_services"
android:background="#drawable/dashboard_bg_selector"
android:clickable="false"
android:elevation="#dimen/dashboard_feature_bg_elevation"
android:focusable="false"
tools:targetApi="lollipop">
<TextView
android:id="#+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="31dp"
android:text="#string/other_detail"
android:textColor="#color/black"
android:textSize="12sp" />
<ImageView
android:id="#+id/otherView"
android:layout_width="130dip"
android:layout_height="130dip"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:contentDescription="#string/other"
app:srcCompat="#drawable/help" />
<TextView
android:id="#+id/otherTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="14dp"
android:clickable="true"
android:gravity="center_vertical|center_horizontal|center"
android:onClick="openOthersView"
android:text="#string/other"
android:textColor="#color/black"
android:textSize="18sp"
android:textStyle="bold" />
</RelativeLayout>
</RelativeLayout>
</RelativeLayout>
You are calling openAccountView method by onClick imageView by this:
android:onClick="openAccountView"
So, no need to add onClicklistener to your imageView.
Remove onClicklistener in openAccountView, Use the below code :
public void openAccountView(View view){
Intent i = new Intent(MainActivity.this, AccountActivity.class);
startActivity(i);
}
Hope this helps.
This is a Noob question. I am sorry if it has been answered. I have been searching but either could not find or understand the answer. Anyway, I am trying to write a simple weight and balance program for a fleet of aircraft but I'm not sure how to proceed.
I'm trying to figure out how to have the program write to a specific field while a certain radio button is checked.
Could anyone be of any assistance? Thank you!
XML
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/activity_weight_and_balance"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context="com.tropicaircharters.android.employee.weightAndBalance">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Aircraft Currently Selected:"
android:layout_weight="1"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/aircraft_selected"
android:layout_weight="1"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingTop="50dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="A" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="B" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="C" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="D" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="E" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="F" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:id="#+id/display_a"
android:text="#string/a_weight" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:id="#+id/display_b"
android:text="#string/b_weight" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:id="#+id/display_c"
android:text="#string/c_weight" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:id="#+id/display_d"
android:text="#string/d_weight" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:id="#+id/display_e"
android:text="#string/e_weight" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:id="#+id/display_f"
android:text="#string/f_weight" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Weight" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:id="#+id/weight_display"
android:text="#string/weight_display" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="CG" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#string/cg_display" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingTop="25dp"
android:layout_weight="1">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Last Weights Entered" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/last_weight"
android:id="#+id/display_last_entry_1" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/last_weight2"
android:id="#+id/display_last_entry_2" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/last_weight3"
android:id="#+id/display_last_entry_3"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/last_weight4"
android:id="#+id/display_last_entry_4" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/last_weight5"
android:id="#+id/display_last_entry_5"/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Fuel Tanks"
android:gravity="center"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_weight="1">
<TextView
android:text="Main Tanks"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/textView5"
android:layout_weight="1"/>
<TextView
android:text="Auxiliary Tanks"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/textView4"
android:layout_weight="1"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/radioButton2"
android:layout_weight="1" />
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/radioButton"
android:layout_weight="1" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_weight="1">
<TextView
android:text="0 gallons"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/textView3"
android:layout_weight="1"/>
<TextView
android:text="0 gallons"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/textView2"
android:layout_weight="1"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_weight="1">
<TextView
android:text="0 pounds"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/textView3"
android:layout_weight="1"/>
<TextView
android:text="0 pounds"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/textView2"
android:layout_weight="1"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:paddingTop="30dp"
android:text="Weight in Section" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RadioGroup
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:id="#+id/radio_section">
<RadioButton
android:id="#+id/radio_section_a"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="onRadioButtonClicked"
android:text="A" />
<RadioButton
android:id="#+id/radio_section_b"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="onRadioButtonClicked"
android:text="B" />
<RadioButton
android:id="#+id/radio_section_c"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="onRadioButtonClicked"
android:text="C" />
<RadioButton
android:id="#+id/radio_section_d"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="onRadioButtonClicked"
android:text="D" />
<RadioButton
android:id="#+id/radio_section_e"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="onRadioButtonClicked"
android:text="E" />
<RadioButton
android:id="#+id/radio_section_f"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="onRadioButtonClicked"
android:text="F" />
</RadioGroup>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="#+id/enter_weight_box"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:gravity="center"
android:inputType="number"
android:text="#string/enter_weight" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:id="#+id/add_weight"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Add Weight"
android:onClick="add_weight"/>
<Button
android:text="Subtract Weight"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/subtract_weight"
android:layout_weight="1"
android:onClick="subtract_weight" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<Button
android:id="#+id/change_aircraft"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Change Aircraft"
android:onClick="change_aircraft"/>
<Button
android:text="Calculator"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/calculator"
android:layout_weight="1"
android:onClick="startActivity(calculator)" />
</LinearLayout>
Java
package com.tropicaircharters.android.employee;
import android.app.Activity;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.Button;
import android.widget.EditText;
import android.view.View.OnClickListener;
import android.widget.RadioButton;
import android.widget.TextView;
import android.view.View;
import static android.R.attr.onClick;
import static android.R.id.input;
import static android.icu.lang.UCharacter.GraphemeClusterBreak.T;
import static android.icu.lang.UCharacter.GraphemeClusterBreak.V;
import static com.tropicaircharters.android.employee.R.id.display_last_entry_1;
import static com.tropicaircharters.android.employee.R.id.subtract_weight;
import static com.tropicaircharters.android.employee.R.string.a_weight;
import static com.tropicaircharters.android.employee.R.string.weight_display;
public class weightAndBalance extends AppCompatActivity {
//These are weights for each section.
int main_tank_gallons = 0;
int main_tank_weight = main_tank_gallons*6;
int aux_tank_gallons = 0;
int aux_tank_weight = aux_tank_gallons*6;
EditText enter_weight_box;
TextView display_a, weight_display, display_last_weight, display_last_weight_2, display_last_weight_3, display_last_weight_4, display_last_weight_5;
Button add_weight, subtract_weight;
RadioButton radio_section_a, radio_section_b, radio_section_c, radio_section_d, radio_section_e, radio_section_f;
double enter_weight, total_weight, a_weight;
String current_section, last_shizzle, last_shizzle2, last_shizzle3, last_shizzle4, last_shizzle5;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_weight_and_balance);
enter_weight_box = (EditText) findViewById(R.id.enter_weight_box);
display_a = (TextView) findViewById(R.id.display_a);
weight_display = (TextView) findViewById(R.id.weight_display);
add_weight = (Button) findViewById(R.id.add_weight);
subtract_weight = (Button) findViewById(R.id.subtract_weight);
display_last_weight = (TextView) findViewById(R.id.display_last_entry_1);
display_last_weight_2 = (TextView) findViewById(R.id.display_last_entry_2);
display_last_weight_3 = (TextView) findViewById(R.id.display_last_entry_3);
display_last_weight_4 = (TextView) findViewById(R.id.display_last_entry_4);
display_last_weight_5 = (TextView) findViewById(R.id.display_last_entry_5);
//This displays adds the entered number to A, the Total,
// and creates the last weights entered log.
add_weight.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
enter_weight = Double.parseDouble(enter_weight_box.getText().toString());
a_weight = a_weight + enter_weight;
total_weight = total_weight + enter_weight;
last_shizzle5 = last_shizzle4;
last_shizzle4 = last_shizzle3;
last_shizzle3 = last_shizzle2;
last_shizzle2 = last_shizzle;
last_shizzle = "Added " + Double.toString(enter_weight) + " in A";
//These create displays for totals and the last entered log.
display_a.setText(Double.toString(a_weight));
weight_display.setText(Double.toString(total_weight));
display_last_weight.setText(last_shizzle);
display_last_weight_2.setText(last_shizzle2);
display_last_weight_3.setText(last_shizzle3);
display_last_weight_4.setText(last_shizzle4);
display_last_weight_5.setText(last_shizzle5);
enter_weight_box.setText("");
}
});
//This displays and subtracts the entered number to A, the Total,
// and creates the last weights entered log.
subtract_weight.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
enter_weight = Double.parseDouble(enter_weight_box.getText().toString());
a_weight = a_weight - enter_weight;
total_weight = total_weight - enter_weight;
last_shizzle5 = last_shizzle4;
last_shizzle4 = last_shizzle3;
last_shizzle3 = last_shizzle2;
last_shizzle2 = last_shizzle;
last_shizzle = "Subtracted " + Double.toString(enter_weight) + " in A";
//These create displays for totals and the last entered log.
display_a.setText(Double.toString(a_weight));
weight_display.setText(Double.toString(total_weight));
display_last_weight.setText("Subtracted "+Double.toString(enter_weight)+" in "+"A");
display_last_weight.setText(last_shizzle);
display_last_weight_2.setText(last_shizzle2);
display_last_weight_3.setText(last_shizzle3);
display_last_weight_4.setText(last_shizzle4);
display_last_weight_5.setText(last_shizzle5);
enter_weight_box.setText("");
}
});
}
}
I have used cutsom dialog box in my MainActivity for popup screen.I have added cross button to close
the popup screen. here in my code, that cross button is showing inside
the popup screen.
Now what i want is it has to show at the border of the popup screen.
please help me to get this..
Below is my code..any help would be appreciated...thanks in advance..
Java File
HomePage.java
import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.graphics.Point;
import android.os.Bundle;
import android.view.Display;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import android.support.v4.app.DialogFragment;
public class HomePage extends Activity {
final Context context = this;
Button b1;
Button b2;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home_page);
b1 = (Button) findViewById(R.id.button6);
b2 = (Button) findViewById(R.id.button7);
b2.setOnClickListener(new OnClickListener(){
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent intent = new Intent(HomePage.this,RegisterPage.class);
startActivity(intent);
}
});
b1.setOnClickListener(new OnClickListener() {
#SuppressLint("NewApi")
#Override
public void onClick(View arg0) {
// custom dialog
final Dialog dialog = new Dialog(context);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(R.layout.activity_login_page);
WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
Display display = wm.getDefaultDisplay(); // getting the screen size of device
Point size = new Point();
display.getSize(size);
int width = size.x - 20; // Set your heights
int height = size.y - 80; // set your widths
WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
lp.copyFrom(dialog.getWindow().getAttributes());
lp.width = width;
lp.height = height;
dialog.getWindow().setAttributes(lp);
dialog.show();
ImageView image = (ImageView) dialog.findViewById(R.id.cancel_btn);
image.setImageResource(R.drawable.cancel2);
image.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
dialog.dismiss();
}
});
Button dialogButton = (Button) dialog.findViewById(R.id.button1);
dialogButton.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
//dialog.dismiss();
Intent intent = new Intent(HomePage.this,CategoryPage.class);
startActivity(intent);
}
});
dialog.show();
}
});
}
}
XML File
activity_home_page.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#fff"
tools:context=".MainActivity" >
<LinearLayout android:id="#+id/header"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#fff"
android:paddingLeft="0dp"
android:paddingRight="0dp"
android:paddingTop="5dip"
android:paddingBottom="5dip">
<ImageView
android:id="#+id/imageView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginTop="0dp"
android:src="#drawable/miiskylogo" />
</LinearLayout>
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="#+id/header" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="163dp"
android:orientation="vertical"
android:paddingBottom="0dp"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin" >
<Button
android:id="#+id/button6"
android:layout_width="230dp"
android:layout_height="50dp"
android:background="#00b0ff"
android:layout_weight="0.1666"
android:textSize="18dp"
android:textColor="#fff"
android:paddingLeft="3dp"
android:layout_gravity="center"
android:layout_marginTop="32dp"
android:drawableLeft="#drawable/lock"
android:text="Login with SVAPP" />
<Button
android:id="#+id/button7"
android:layout_width="230dp"
android:layout_height="50dp"
android:background="#00b0ff"
android:layout_weight="0.1666"
android:textSize="18dp"
android:textColor="#fff"
android:paddingLeft="3dp"
android:layout_gravity="center"
android:layout_marginTop="15dp"
android:drawableLeft="#drawable/regis"
android:text="Register with SVAPP" />
</LinearLayout>
</ScrollView>
</RelativeLayout>
activity_login_page.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#fff"
tools:context="com.example.miiskyproject.Login" >
<ImageView
android:id="#+id/cancel_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:src="#drawable/cancel2" />
<ImageView
android:id="#+id/imageView1"
android:layout_width="130dp"
android:layout_height="90dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="34dp"
android:src="#drawable/miiskylogo" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent">
<EditText
android:id="#+id/editText1"
android:layout_width="80dp"
android:layout_height="35dp"
android:layout_marginTop="190dp"
android:layout_marginLeft="15dp"
android:layout_marginRight="10dp"
android:background="#drawable/loginedit"
android:ems="6"
android:hint="User Name"
android:padding="8dp"
android:textColor="#000"
android:textStyle="bold"
android:textColorHint="#bdbdbd"
android:textSize="13dp" >
<requestFocus />
</EditText>
<EditText
android:id="#+id/editText2"
android:layout_width="80dp"
android:layout_height="35dp"
android:layout_marginTop="190dp"
android:layout_marginRight="15dp"
android:background="#drawable/loginedit"
android:ems="6"
android:hint="Password"
android:inputType="textPassword"
android:padding="8dp"
android:textColor="#000"
android:textStyle="bold"
android:textColorHint="#bdbdbd"
android:textSize="13dp" />
<Button
android:id="#+id/button1"
android:layout_width="70dp"
android:layout_height="35dp"
android:layout_marginRight="20dp"
android:layout_marginTop="190dp"
android:background="#drawable/loginbutton"
android:ems="7"
android:text="Login"
android:textColor="#fff"
android:textSize="12dp" />
</LinearLayout>
<LinearLayout
android:id="#+id/panelInsurance7"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginLeft="15dp"
android:layout_marginTop="10dp"
>
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="225dp"
android:text="Forget Your Password?"
android:textSize="13dp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:id="#+id/linear1"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginLeft="15dp"
android:layout_marginTop="10dp">
<TextView
android:id="#+id/textView2"
android:layout_width="250dp"
android:layout_height="wrap_content"
android:layout_marginTop="280dp"
android:padding="10dp"
android:layout_marginRight="20dp"
android:text="Lorem Ipsum dolor sit amet,"
android:background="#drawable/loginedit"
android:textSize="18dp"
android:textStyle="bold" />
</LinearLayout>
</RelativeLayout>
I want cross button something like the image below.
Click Here
Try this solution:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#fff"
tools:context="com.example.miiskyproject.Login" >
<LinearLayout
android:id="#+id/cancel_layuot"
android:layout_width="match_parent"
android:gravity="right"
android:background="#android:color/transparent"
android:layout_height="wrap_content" >
<ImageView
android:id="#+id/cancel_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:src="#drawable/ic_launcher" />
</LinearLayout>
<ImageView
android:id="#+id/imageView1"
android:layout_width="130dp"
android:layout_height="90dp"
android:layout_below="#+id/cancel_layuot"
android:layout_centerHorizontal="true"
android:layout_marginTop="34dp"
android:src="#drawable/left_arrow" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_below="#+id/cancel_layuot" >
<EditText
android:id="#+id/editText1"
android:layout_width="80dp"
android:layout_height="35dp"
android:layout_marginLeft="15dp"
android:layout_marginRight="10dp"
android:layout_marginTop="190dp"
android:background="#drawable/ic_launcher"
android:ems="6"
android:hint="User Name"
android:padding="8dp"
android:textColor="#000"
android:textColorHint="#bdbdbd"
android:textSize="13dp"
android:textStyle="bold" >
<requestFocus />
</EditText>
<EditText
android:id="#+id/editText2"
android:layout_width="80dp"
android:layout_height="35dp"
android:layout_marginRight="15dp"
android:layout_marginTop="190dp"
android:background="#drawable/ic_launcher"
android:ems="6"
android:hint="Password"
android:inputType="textPassword"
android:padding="8dp"
android:textColor="#000"
android:textColorHint="#bdbdbd"
android:textSize="13dp"
android:textStyle="bold" />
<Button
android:id="#+id/button1"
android:layout_width="70dp"
android:layout_height="35dp"
android:layout_marginRight="20dp"
android:layout_marginTop="190dp"
android:background="#drawable/ic_launcher"
android:ems="7"
android:text="Login"
android:textColor="#fff"
android:textSize="12dp" />
</LinearLayout>
<LinearLayout
android:id="#+id/panelInsurance7"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginLeft="15dp"
android:layout_marginTop="10dp" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="225dp"
android:text="Forget Your Password?"
android:textSize="13dp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:id="#+id/linear1"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_below="#+id/cancel_layuot"
android:layout_marginLeft="15dp"
android:layout_marginTop="10dp" >
<TextView
android:id="#+id/textView2"
android:layout_width="250dp"
android:layout_height="wrap_content"
android:layout_marginRight="20dp"
android:layout_marginTop="280dp"
android:background="#drawable/ic_launcher"
android:padding="10dp"
android:text="Lorem Ipsum dolor sit amet,"
android:textSize="18dp"
android:textStyle="bold" />
</LinearLayout>
</RelativeLayout>
You will see something like this:
Just replace image ic_launcher with the appropriated image.
Problem is that I am taking thumbnail from Youtube of the video and when I am clicking on that Image that is redirecting me to Youtube but problem is that i want to show the image of a play Icon on that Image that I am taking from Youtube..Hope so u have Understood what I am asking.
can any One Help me.
package com.dotocto.ipartner;
import java.util.ArrayList;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.dotocto.ipartner.dataset.VedioDataSet;
import com.dotocto.ipartner.netio.WebServices;
import com.dotocto.ipartner.patten.ImageLoader;
import com.dotocto.ipartner.patten.UtilClassForValidations;
public class VideoScreen extends Activity implements OnClickListener {
private ImageView[] images;
private ImageLoader imageloader;
//private ImageView imageView;
private TextView vedio_text;
private LinearLayout image_layout;
ArrayList<VedioDataSet> imageslist;
ImageView i11;
#Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.video_screen);
try{
vedio_text = (TextView)findViewById(R.id.vedio_text);
image_layout = (LinearLayout)findViewById(R.id.image_layout);
imageloader = new ImageLoader(VideoScreen.this);
imageslist = new ArrayList<VedioDataSet>();
i11= (ImageView) findViewById(R.id.imageView1);
}catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
}
#Override
protected void onStart() {
// TODO Auto-generated method stub
super.onStart();
try{
LinearLayout vedio_lay = (LinearLayout) findViewById(R.id.vedio_lay);
vedio_lay.setBackgroundResource(R.drawable.selected);
vedio_text .setTextColor(android.graphics.Color.BLUE);
if(imageslist == null || imageslist.size() <= 0)
{
new PostDataToServer().execute();
}
}catch (Exception e) {
// TODO: handle exception
}
}
class PostDataToServer extends AsyncTask<String, Integer, ArrayList<VedioDataSet>> {
#Override
protected ArrayList<VedioDataSet> doInBackground(String... arg0)
{
return WebServices.VedioActivity();
}
#Override
protected void onPostExecute(ArrayList<VedioDataSet > result)//onPostExecute(Result), invoked on the UI thread after the background computation finishes. The result of the background computation is passed to this step as a parameter.
{
// TODO Auto-generated method stub
super.onPostExecute(result);
// if(pd != null && pd.isShowing())
// pd.dismiss();
try{
if(result != null)
{
if(result.get(0).getStatus().equalsIgnoreCase("success"))
{
imageslist = result;
for(int j=0; j<imageslist.size(); j++)
{
LinearLayout hlinearlayout = new LinearLayout(VideoScreen.this);
hlinearlayout.setOrientation(LinearLayout.HORIZONTAL);
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT,
1f);
hlinearlayout.setWeightSum(3);
final VedioDataSet record1 = imageslist.get(j);
ImageView img1 = new ImageView(VideoScreen.this);
LinearLayout.LayoutParams params1 = layoutParams;
params1.weight = 1f;
params1.setMargins(2, 2, 2, 2);
img1.setLayoutParams(params1);
img1.setVisibility(View.VISIBLE);
img1.setTag(record1.getYoutubeimg());
//i11.setVisibility(View.VISIBLE);
imageloader.DisplayImage(record1.getYoutubeimg(), VideoScreen.this, img1);
hlinearlayout.addView(img1);
playVideo(img1,record1);
j ++;
if(j < imageslist.size())
{
final VedioDataSet record2 = imageslist.get(j);
ImageView img2 = new ImageView(VideoScreen.this);
LinearLayout.LayoutParams params2 = layoutParams;
params2.weight = 1f;
params2.setMargins(2, 2, 2, 2);
img2.setLayoutParams(params2);
img2.setVisibility(View.VISIBLE);
img2.setTag(record2.getYoutubeimg());
imageloader.DisplayImage(record2.getYoutubeimg(), VideoScreen.this, img2);
hlinearlayout.addView(img2);
playVideo(img2,record2);
}
j++;
if(j < imageslist.size())
{
final VedioDataSet record3 = imageslist.get(j);
ImageView img3 = new ImageView(VideoScreen.this);
LinearLayout.LayoutParams params3 = layoutParams;
params3.weight = 1f;
params3.setMargins(2, 2, 2, 2);
img3.setLayoutParams(params3);
img3.setVisibility(View.VISIBLE);
img3.setTag(record3.getYoutubeimg());
imageloader.DisplayImage(record3.getYoutubeimg(), VideoScreen.this, img3);
hlinearlayout.addView(img3);
playVideo(img3,record3);
}
image_layout.addView(hlinearlayout);
}
}
else
UtilClassForValidations.alatMassageBox(VideoScreen.this,result.get(0).getErrormsg() );
}
else
UtilClassForValidations.alatMassageBox(VideoScreen.this, "We're sorry! There has been some error " +
"occured during serching video screen images and vedios. Please try again after some time.");
}
catch (Exception e)
{
// TODO: handle exception
e.printStackTrace();
}
}
}
public void playVideo(ImageView x ,final VedioDataSet y){
x.setOnClickListener(new OnClickListener()
{
#Override
public void onClick(View v)
{
try
{
if(y.getVideourl() != null && y.getVideourl().length() >0)
{
Uri uri = Uri.parse(y.getVideourl());
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);
// finish();
}
else
{
UtilClassForValidations.alatMassageBox(VideoScreen.this, "We're sorry! " +
" The video Url is can not provided by server side" +
" Please try again after some time.");
}
}
catch (Exception e)
{
// TODO: handle exception
e.printStackTrace();
}
}
});
}
public void onClick(View v) {
// TODO Auto-generated method stub
switch (v.getId())
{
case R.id.give_icon:
Intent give = new Intent(VideoScreen.this, PaymentActivity.class);
give.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
startActivity(give);
// finish();
break;
case R.id.blog_icon:
Intent blog = new Intent(VideoScreen.this, BlogActivity.class);
blog.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
startActivity(blog);
// finish();
break;
case R.id.arms_icon:
Intent vedio = new Intent(VideoScreen.this, PartnershipArms.class);
vedio.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
startActivity(vedio);
// finish();
break;
case R.id.icon_contact:
Intent contact = new Intent(VideoScreen.this, ContactUsActivity.class);
contact.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
startActivity(contact);
// finish(;
break;
}
}
}
// this is my XML
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/inner_bg"
android:orientation="vertical" >
<RelativeLayout
android:id="#+id/header_bar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/bottom_bg" >
<TextView
android:id="#+id/header_bar_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="VIDEOS"
android:textColor="#ffffff"
android:textSize="20sp"
android:typeface="normal" />
</RelativeLayout>
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/linearLayout"
android:layout_below="#+id/header_bar"
android:layout_centerHorizontal="true"
android:scrollbars="none" >
<LinearLayout
android:id="#+id/image_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:id="#+id/image_ineerlayout2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:gravity="center"
android:orientation="horizontal"
android:weightSum="3" >
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
>
<ImageView
android:id="#+id/par_arm3"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:clickable="true"
android:src="#drawable/bottom_bg"
/>"
<ImageView
android:id="#+id/imageView1"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_weight="1"
android:src="#drawable/play_btn1"
android:keepScreenOn="true"
android:clickable="true"/>
</FrameLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
>
<ImageView
android:id="#+id/par_arm4"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="5dp"
android:layout_weight="1"
android:clickable="true"
android:src="#drawable/logo_holder" />
<ImageView
android:id="#+id/imageView2"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_weight="1"
android:src="#drawable/play_btn1"
android:keepScreenOn="true"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
>
<ImageView
android:id="#+id/par_arm5"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="5dp"
android:layout_weight="1"
android:clickable="true"
android:src="#drawable/logo_holder" />
<ImageView
android:id="#+id/imageView3"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_weight="1"
android:src="#drawable/play_btn1" />
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/image_ineerlayout3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_weight="3"
android:gravity="center"
android:orientation="horizontal" >
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
>
<ImageView
android:id="#+id/par_arm6"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:clickable="true"
android:src="#drawable/logo_holder" />
<ImageView
android:id="#+id/imageView4"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_weight="1"
android:src="#drawable/play_btn1" />
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
>
<ImageView
android:id="#+id/par_arm7"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="5dp"
android:layout_weight="1"
android:clickable="true"
android:src="#drawable/logo_holder" />
<ImageView
android:id="#+id/imageView6"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_weight="1"
android:src="#drawable/play_btn1" />
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
>
<ImageView
android:id="#+id/par_arm8"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="5dp"
android:layout_weight="1"
android:clickable="true"
android:src="#drawable/logo_holder" />
<ImageView
android:id="#+id/imageView5"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_weight="1"
android:src="#drawable/play_btn1" />
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/image_ineerlayout4"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_weight="3"
android:gravity="center"
android:orientation="horizontal" >
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
>
<ImageView
android:id="#+id/par_arm9"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:clickable="true"
android:src="#drawable/logo_holder" />
<ImageView
android:id="#+id/imageView7"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_weight="1"
android:src="#drawable/play_btn1" />
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
>
<ImageView
android:id="#+id/par_arm10"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="5dp"
android:layout_weight="1"
android:clickable="true"
android:src="#drawable/logo_holder" />
<ImageView
android:id="#+id/imageView88"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_weight="1"
android:src="#drawable/play_btn1"
android:keepScreenOn="true" />
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
>
<ImageView
android:id="#+id/par_arm11"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="5dp"
android:layout_weight="1"
android:clickable="true"
android:src="#drawable/logo_holder" />
<ImageView
android:id="#+id/imageView77"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_weight="1"
android:src="#drawable/play_btn1"
android:keepScreenOn="true"/>
</RelativeLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>
<LinearLayout
android:id="#+id/linearLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#drawable/bottom_bg"
android:orientation="vertical" >
<LinearLayout
android:id="#+id/bott_iner_linearLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal|center_vertical"
android:layout_marginTop="12dp"
android:gravity="center"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:orientation="vertical" >
<com.dotocto.ipartner.patten.SAutoBgButton
android:id="#+id/arms_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="6dp"
android:background="#drawable/arms_icon"
android:onClick="onClick" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:text="ARMS"
android:textColor="#ffffff"
android:textSize="14sp"
android:typeface="normal" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:orientation="vertical" >
<com.dotocto.ipartner.patten.SAutoBgButton
android:id="#+id/give_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="2dp"
android:background="#drawable/give_icon"
android:onClick="onClick" />
<TextView
android:id="#+id/give_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="GIVE"
android:textColor="#ffffff"
android:textSize="14sp"
android:typeface="normal" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:orientation="vertical" >
<com.dotocto.ipartner.patten.SAutoBgButton
android:id="#+id/blog_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="6dp"
android:background="#drawable/blog_icon"
android:onClick="onClick" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="3dp"
android:text="BLOG"
android:textColor="#ffffff"
android:textSize="14sp"
android:typeface="normal" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:orientation="vertical" >
<com.dotocto.ipartner.patten.SAutoBgButton
android:id="#+id/vedio_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="6dp"
android:layout_marginTop="2dp"
android:background="#drawable/vedio_icon"
android:onClick="onClick" />
<TextView
android:id="#+id/vedio_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="3dp"
android:text="VIDEO"
android:textColor="#ffffff"
android:textSize="14sp"
android:typeface="normal" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:orientation="vertical" >
<com.dotocto.ipartner.patten.SAutoBgButton
android:id="#+id/icon_contact"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="25dp"
android:background="#drawable/icon_contact"
android:onClick="onClick" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="5dp"
android:layout_marginTop="2dp"
android:text="CONTACT US"
android:textColor="#ffffff"
android:textSize="14sp"
android:typeface="normal" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</RelativeLayout>
to use overlapping images in layout you can use frame layout http://developer.android.com/reference/android/widget/FrameLayout.html
I have 18 ScrollViews in a LinearLayout, that change their state of visibility when some integers are added up when buttons are clicked.
The problem is that the if statement from my code works only when I have just 4-5 ScrollViews.
But when I have all my layouts in place, it does nothing.
What have I done wrong?
activity_main.xml
<RelativeLayout
android:id="#+id/question_1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/question_1"
android:visibility="gone" >
<Button
android:id="#+id/next_btn1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginRight="10dp"
android:layout_below="#+id/b1_btn"
android:layout_marginTop="20dp"
android:background="#drawable/next_button" />
<Button
android:id="#+id/b1_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginRight="10dp"
android:layout_below="#+id/a1_btn"
android:layout_marginTop="20dp"
android:background="#drawable/choix_button" />
<Button
android:id="#+id/a1_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginRight="10dp"
android:layout_marginTop="55dp"
android:background="#drawable/choix_button" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/question_2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/question_2"
android:visibility="gone" >
<Button
android:id="#+id/next_btn2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginRight="10dp"
android:layout_below="#+id/b2_btn"
android:layout_marginTop="20dp"
android:background="#drawable/next_button" />
<Button
android:id="#+id/b2_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginRight="10dp"
android:layout_below="#+id/a2_btn"
android:layout_marginTop="20dp"
android:background="#drawable/choix_button" />
<Button
android:id="#+id/a2_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginRight="10dp"
android:layout_marginTop="55dp"
android:background="#drawable/choix_button" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/question_3"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/question_3"
android:visibility="gone" >
<Button
android:id="#+id/next_btn3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginRight="10dp"
android:layout_below="#+id/b3_btn"
android:layout_marginTop="20dp"
android:background="#drawable/next_button" />
<Button
android:id="#+id/b3_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginRight="10dp"
android:layout_below="#+id/a3_btn"
android:layout_marginTop="20dp"
android:background="#drawable/choix_button" />
<Button
android:id="#+id/a3_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginRight="10dp"
android:layout_marginTop="55dp"
android:background="#drawable/choix_button" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/question_4"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/question_4"
android:visibility="gone" >
<Button
android:id="#+id/result_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginRight="10dp"
android:layout_below="#+id/b4_btn"
android:layout_marginTop="20dp"
android:background="#drawable/next_button" />
<Button
android:id="#+id/b4_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginRight="10dp"
android:layout_below="#+id/a4_btn"
android:layout_marginTop="20dp"
android:background="#drawable/choix_button" />
<Button
android:id="#+id/a4_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginRight="10dp"
android:layout_marginTop="55dp"
android:background="#drawable/choix_button" />
<Button
android:id="#+id/back_btn3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/b4_btn"
android:layout_marginLeft="10dp"
android:layout_marginTop="20dp"
android:background="#drawable/avant_button" />
</RelativeLayout>
<ScrollView
android:id="#+id/eerner_scroll"
android:layout_width="550dp"
android:layout_height="650dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="false"
android:layout_marginTop="80dp"
android:scrollbarStyle="insideOverlay"
android:scrollbars="vertical"
android:visibility="gone" >
<ImageView
android:id="#+id/eerner_image"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="0dp"
android:layout_marginTop="0dp"
android:contentDescription="#string/eerner"
android:scaleType="fitXY"
android:src="#drawable/eerner"
android:visibility="visible" />
</ScrollView>
<ScrollView
android:id="#+id/frameinfo"
android:layout_width="550dp"
android:layout_height="650dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="false"
android:layout_marginTop="80dp"
android:scrollbarStyle="insideOverlay"
android:scrollbars="vertical"
android:visibility="gone" >
<ImageView
android:id="#+id/infoscreen"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="0dp"
android:layout_marginTop="0dp"
android:contentDescription="#string/infoscreen"
android:scaleType="fitXY"
android:src="#drawable/info"
android:visibility="visible" />
</ScrollView>
<ScrollView
android:id="#+id/eerney_scroll"
android:layout_width="550dp"
android:layout_height="650dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="false"
android:layout_marginTop="80dp"
android:scrollbarStyle="insideOverlay"
android:scrollbars="vertical"
android:visibility="gone" >
<ImageView
android:id="#+id/eerney"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="0dp"
android:layout_marginTop="0dp"
android:contentDescription="#string/eerney"
android:scaleType="fitXY"
android:src="#drawable/eerney"
android:visibility="visible" />
</ScrollView>
<ScrollView
android:id="#+id/einteg_scroll"
android:layout_width="550dp"
android:layout_height="650dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="false"
android:layout_marginTop="80dp"
android:scrollbarStyle="insideOverlay"
android:scrollbars="vertical"
android:visibility="gone" >
<ImageView
android:id="#+id/einteg"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="0dp"
android:layout_marginTop="0dp"
android:contentDescription="#string/einteg"
android:scaleType="fitXY"
android:src="#drawable/einteg"
android:visibility="visible" />
</ScrollView>
<ScrollView
android:id="#+id/einter_scroll"
android:layout_width="550dp"
android:layout_height="650dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="false"
android:layout_marginTop="80dp"
android:scrollbarStyle="insideOverlay"
android:scrollbars="vertical"
android:visibility="gone" >
<ImageView
android:id="#+id/einter"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="0dp"
android:layout_marginTop="0dp"
android:contentDescription="#string/einter"
android:scaleType="fitXY"
android:src="#drawable/einter"
android:visibility="visible" />
</ScrollView>
<ScrollView
android:id="#+id/ekommr_scroll"
android:layout_width="550dp"
android:layout_height="650dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="false"
android:layout_marginTop="80dp"
android:scrollbarStyle="insideOverlay"
android:scrollbars="vertical"
android:visibility="gone" >
<ImageView
android:id="#+id/ekommr"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="0dp"
android:layout_marginTop="0dp"
android:contentDescription="#string/ekommr"
android:scaleType="fitXY"
android:src="#drawable/ekommr"
android:visibility="visible" />
</ScrollView>
<ScrollView
android:id="#+id/ekommy_scroll"
android:layout_width="550dp"
android:layout_height="650dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="false"
android:layout_marginTop="80dp"
android:scrollbarStyle="insideOverlay"
android:scrollbars="vertical"
android:visibility="gone" >
<ImageView
android:id="#+id/ekommy"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="0dp"
android:layout_marginTop="0dp"
android:contentDescription="#string/ekommy"
android:scaleType="fitXY"
android:src="#drawable/ekommy"
android:visibility="visible" />
</ScrollView>
<ScrollView
android:id="#+id/ekompb_scroll"
android:layout_width="550dp"
android:layout_height="650dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="false"
android:layout_marginTop="80dp"
android:scrollbarStyle="insideOverlay"
android:scrollbars="vertical"
android:visibility="gone" >
<ImageView
android:id="#+id/ekompb"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="0dp"
android:layout_marginTop="0dp"
android:contentDescription="#string/ekompb"
android:scaleType="fitXY"
android:src="#drawable/ekompb"
android:visibility="visible" />
</ScrollView>
<ScrollView
android:id="#+id/ekompg_scroll"
android:layout_width="550dp"
android:layout_height="650dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="false"
android:layout_marginTop="80dp"
android:scrollbarStyle="insideOverlay"
android:scrollbars="vertical"
android:visibility="gone" >
<ImageView
android:id="#+id/ekompg"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="0dp"
android:layout_marginTop="0dp"
android:contentDescription="#string/ekompg"
android:scaleType="fitXY"
android:src="#drawable/ekompg"
android:visibility="visible" />
</ScrollView>
<ScrollView
android:id="#+id/ekoorb_scroll"
android:layout_width="550dp"
android:layout_height="650dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="false"
android:layout_marginTop="80dp"
android:scrollbarStyle="insideOverlay"
android:scrollbars="vertical"
android:visibility="gone" >
<ImageView
android:id="#+id/ekoorb"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="0dp"
android:layout_marginTop="0dp"
android:contentDescription="#string/ekoorb"
android:scaleType="fitXY"
android:src="#drawable/ekoorb"
android:visibility="visible" />
</ScrollView>
<ScrollView
android:id="#+id/ekoory_scroll"
android:layout_width="550dp"
android:layout_height="650dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="false"
android:layout_marginTop="80dp"
android:scrollbarStyle="insideOverlay"
android:scrollbars="vertical"
android:visibility="gone" >
<ImageView
android:id="#+id/ekoory"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="0dp"
android:layout_marginTop="0dp"
android:contentDescription="#string/ekoory"
android:scaleType="fitXY"
android:src="#drawable/ekoory"
android:visibility="visible" />
</ScrollView>
<ScrollView
android:id="#+id/epragb_scroll"
android:layout_width="550dp"
android:layout_height="650dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="false"
android:layout_marginTop="80dp"
android:scrollbarStyle="insideOverlay"
android:scrollbars="vertical"
android:visibility="gone" >
<ImageView
android:id="#+id/epragb"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="0dp"
android:layout_marginTop="0dp"
android:contentDescription="#string/epragb"
android:scaleType="fitXY"
android:src="#drawable/epragb"
android:visibility="visible" />
</ScrollView>
<ScrollView
android:id="#+id/epragy_scroll"
android:layout_width="550dp"
android:layout_height="650dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="false"
android:layout_marginTop="80dp"
android:scrollbarStyle="insideOverlay"
android:scrollbars="vertical"
android:visibility="gone" >
<ImageView
android:id="#+id/epragy"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="0dp"
android:layout_marginTop="0dp"
android:contentDescription="#string/epragy"
android:scaleType="fitXY"
android:src="#drawable/epragy"
android:visibility="visible" />
</ScrollView>
<ScrollView
android:id="#+id/eprufb_scroll"
android:layout_width="550dp"
android:layout_height="650dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="false"
android:layout_marginTop="80dp"
android:scrollbarStyle="insideOverlay"
android:scrollbars="vertical"
android:visibility="gone" >
<ImageView
android:id="#+id/eprufb"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="0dp"
android:layout_marginTop="0dp"
android:contentDescription="#string/eprufb"
android:scaleType="fitXY"
android:src="#drawable/eprufb"
android:visibility="visible" />
</ScrollView>
<ScrollView
android:id="#+id/eprufg_scroll"
android:layout_width="550dp"
android:layout_height="650dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="false"
android:layout_marginTop="80dp"
android:scrollbarStyle="insideOverlay"
android:scrollbars="vertical"
android:visibility="gone" >
<ImageView
android:id="#+id/eprufg"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="0dp"
android:layout_marginTop="0dp"
android:contentDescription="#string/eprufg"
android:scaleType="fitXY"
android:src="#drawable/eprufg"
android:visibility="visible" />
</ScrollView>
<ScrollView
android:id="#+id/estabg_scroll"
android:layout_width="550dp"
android:layout_height="650dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="false"
android:layout_marginTop="80dp"
android:scrollbarStyle="insideOverlay"
android:scrollbars="vertical"
android:visibility="gone" >
<ImageView
android:id="#+id/estabg"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="0dp"
android:layout_marginTop="0dp"
android:contentDescription="#string/estabg"
android:scaleType="fitXY"
android:src="#drawable/estabg"
android:visibility="visible" />
</ScrollView>
<ScrollView
android:id="#+id/estabr_scroll"
android:layout_width="550dp"
android:layout_height="650dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="false"
android:layout_marginTop="80dp"
android:scrollbarStyle="insideOverlay"
android:scrollbars="vertical"
android:visibility="gone" >
<ImageView
android:id="#+id/estabr"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="0dp"
android:layout_marginTop="0dp"
android:contentDescription="#string/estabr"
android:scaleType="fitXY"
android:src="#drawable/estabr"
android:visibility="visible" />
</ScrollView>
</LinearLayout>
ActivityMain.java
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.ScrollView;
public class MainActivity extends Activity {
int a1_val = 0;
int b1_val = 0;
int a2_val = 0;
int b2_val = 0;
int a3_val = 0;
int b3_val = 0;
int a4_val = 0;
int b4_val = 0;
int eerner = 4844;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//Buttons for start screen
ImageButton clicks =(ImageButton)findViewById(R.id.clicks);
ImageButton new_test_btn =(ImageButton)findViewById(R.id.new_test_btn);
ImageButton view_profile_btn =(ImageButton)findViewById(R.id.view_profile_btn);
ImageButton home_btn =(ImageButton)findViewById(R.id.home_btn);
ImageButton info_btn =(ImageButton)findViewById(R.id.info_btn);
//Buttons for question_1
Button a1_btn =(Button)findViewById(R.id.a1_btn);
Button b1_btn =(Button)findViewById(R.id.b1_btn);
Button next_btn1 =(Button)findViewById(R.id.next_btn1);
//Buttons for question_2
Button a2_btn =(Button)findViewById(R.id.a2_btn);
Button b2_btn =(Button)findViewById(R.id.b2_btn);
Button next_btn2 =(Button)findViewById(R.id.next_btn2);
Button back_btn1 =(Button)findViewById(R.id.back_btn1);
//Buttons for question_3
Button a3_btn =(Button)findViewById(R.id.a3_btn);
Button b3_btn =(Button)findViewById(R.id.b3_btn);
Button next_btn3 =(Button)findViewById(R.id.next_btn3);
Button back_btn2 =(Button)findViewById(R.id.back_btn2);
//Buttons for question_4
Button a4_btn =(Button)findViewById(R.id.a4_btn);
Button b4_btn =(Button)findViewById(R.id.b4_btn);
Button result_btn =(Button)findViewById(R.id.result_btn);
Button back_btn3 =(Button)findViewById(R.id.back_btn3);
// a1 click
a1_btn.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {a1_val = 1;};});
// b1 click
b1_btn.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {b1_val = 5;};});
//a2 click
a2_btn.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {a2_val = 22;};});
//b2 click
b2_btn.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {b2_val = 66;};});
//a3 click
a3_btn.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {a3_val = 333;};});
//b3 click
b3_btn.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {b3_val = 777;};});
//a4 click
a4_btn.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {a4_val = 4444;};});
//b4 click
b4_btn.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {b4_val = 8888;};});
//result click
result_btn.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
if (a1_val + b2_val + a3_val + a4_val == eerner);
ScrollView eerner_scroll = (ScrollView)findViewById(R.id.eerner_scroll);
eerner_scroll.setVisibility(ScrollView.VISIBLE);
};});
It's a little unclear what you're asking, but assuming it's the if that's causing you trouble:
if (a1_val + b2_val + a3_val + a4_val == eerner);
... you should get rid of the ; and put the conditional code in a {} block. As it is now, if the condition evaluates to true, an empty statement block is executed and then the code proceeds with ScrollView eerner_scroll = ... regardless of what was in the conditional if.