hi to everyone i have this code in xml and i want transform this to java
<TableRow>
<ImageButton android:id="#+id/btnImg1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="80dp"
android:layout_marginTop="75dp"
android:src="#drawable/one"/>
<ImageButton android:id="#+id/btnImg2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="75dp"
android:src="#drawable/two"/>
<ImageButton android:id="#+id/btnImg13"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="75dp"
android:src="#drawable/three"/>
</TableRow>
<TableRow>
<ImageButton android:id="#+id/btnImg4"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="80dp"
android:src="#drawable/four"/>
<ImageButton android:id="#+id/btnImg5"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:src="#drawable/five"/>
<ImageButton android:id="#+id/btnImg6"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:src="#drawable/six"/>
</TableRow>
<TableRow>
<ImageButton android:id="#+id/btnImg7"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="80dp"
android:src="#drawable/seven"
android:onClick="onClick"/>
<ImageButton android:id="#+id/btnImg8"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:src="#drawable/eight"
android:onClick="onClick2"/>
<ImageButton android:id="#+id/btnImg9"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:src="#drawable/nine"
android:onClick="onClick3"/>
</TableRow>
<TableRow>
<ImageButton android:id="#+id/btnImg10"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="80dp"
android:layout_marginTop="50dp"
android:src="#drawable/seven"/>
<ImageButton android:id="#+id/btnImg11"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="50dp"
android:src="#drawable/eight"/>
<ImageButton android:id="#+id/btnImg12"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="50dp"
android:src="#drawable/nine"/>
</TableRow>
i write this in java but when i run all the imagebutton are duplicate on together:
public class GameActivity extends Activity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// setContentView(R.layout.main);
LayoutParams params =
new TableRow.LayoutParams(
LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT);
TableRow table = new TableRow(this);
table.setOrientation(TableRow.VERTICAL);
ImageButton ib = new ImageButton(this);
ib.setImageResource(R.drawable.one);
ib.setLayoutParams(params);
ib.setOnClickListener(new View.OnClickListener()
{
public void onClick(View v){
Toast.makeText(getBaseContext(),"button clicked",Toast.LENGTH_SHORT).show();
}
});
ImageButton ib2 = new ImageButton(this);
ib.setImageResource(R.drawable.two);
ib.setLayoutParams(params);
ib.setOnClickListener(new View.OnClickListener()
{
public void onClick(View v){
Toast.makeText(getBaseContext(),"button clicked",Toast.LENGTH_SHORT).show();
}
});
table.addView(ib);
table.addView(ib2);
TableRow.LayoutParams layoutParams=
new TableRow.LayoutParams(
LayoutParams.MATCH_PARENT,
LayoutParams.MATCH_PARENT );
this.addContentView(table, layoutParams);
}
this is just for 2 imagebutton but this hapend too...thank you
Related
I make a programm for android and i have a problem. Also i used navigator drawer and fragments inside my app. I found a lot of information in the interner, but i did not find, what i wanted.
I want to make a custom keyboard inside my app.
I did this
<LinearLayout
android:visibility="gone"
android:id="#+id/keyBoard"
android:layout_width="match_parent"
android:layout_height="200dp"
android:gravity="bottom"
android:layout_gravity="bottom"
android:background="#color/colorPrimary"
android:orientation="vertical">
<LinearLayout
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="45dp"
android:orientation="horizontal">
<Button
android:textAllCaps="false"
android:id="#+id/graphE"
android:layout_width="0dp"
android:layout_height="45dp"
android:layout_weight="1"
android:text="#string/key_e"/>
<Button
android:textAllCaps="false"
android:id="#+id/graphPi"
android:layout_width="0dp"
android:layout_height="45dp"
android:layout_weight="1"
android:text="#string/key_pi"/>
<Button
android:id="#+id/graphLeftBracket"
android:layout_width="0dp"
android:layout_height="45dp"
android:layout_weight="1"
android:text="#string/key_bracket_left"/>
<Button
android:id="#+id/graphRightBracket"
android:layout_width="0dp"
android:layout_height="45dp"
android:layout_weight="1"
android:text="#string/key_bracket_right"/>
<Button
android:id="#+id/graphLeftSquareBracket"
android:layout_width="0dp"
android:layout_height="45dp"
android:layout_weight="1"
android:text="#string/key_bracket_square_left"/>
<Button
android:id="#+id/graphRightSquareBracket"
android:layout_width="0dp"
android:layout_height="45dp"
android:layout_weight="1"
android:text="#string/key_bracket_square_right"/>
<Button
android:id="#+id/graphDegree"
android:layout_width="0dp"
android:layout_height="45dp"
android:layout_weight="1"
android:text="#string/key_degree"/>
<Button
android:id="#+id/graphDelete"
android:layout_width="0dp"
android:layout_height="45dp"
android:layout_weight="1"
android:layout_gravity="center_horizontal"
android:drawableBottom="#drawable/ic_clear"/>
</LinearLayout>
<LinearLayout
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="45dp"
android:orientation="horizontal">
<Button
android:textAllCaps="false"
android:id="#+id/graphAcos"
android:layout_width="0dp"
android:layout_height="45dp"
android:layout_weight="2"
android:text="#string/key_acos"/>
<Button
android:textAllCaps="false"
android:id="#+id/graphCos"
android:layout_width="0dp"
android:layout_height="45dp"
android:layout_weight="1"
android:text="#string/key_cos"/>
<Button
android:id="#+id/graphX"
android:layout_width="0dp"
android:layout_height="45dp"
android:layout_weight="1"
android:text="#string/button_x"/>
<Button
android:id="#+id/graphOne"
android:layout_width="0dp"
android:layout_height="45dp"
android:layout_weight="1"
android:text="#string/key_one"/>
<Button
android:id="#+id/graphTwo"
android:layout_width="0dp"
android:layout_height="45dp"
android:layout_weight="1"
android:text="#string/key_two"/>
<Button
android:id="#+id/graphThree"
android:layout_width="0dp"
android:layout_height="45dp"
android:layout_weight="1"
android:text="#string/key_three"/>
<Button
android:id="#+id/graphMultiply"
android:layout_width="0dp"
android:layout_height="45dp"
android:layout_weight="1"
android:layout_gravity="center_horizontal"
android:drawableBottom="#drawable/ic_multiply"/>
</LinearLayout>
<LinearLayout
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="45dp"
android:orientation="horizontal">
<Button
android:textAllCaps="false"
android:id="#+id/graphAtan"
android:layout_width="0dp"
android:layout_height="45dp"
android:layout_weight="2"
android:text="#string/key_atan"/>
<Button
android:textAllCaps="false"
android:id="#+id/graphTan"
android:layout_width="0dp"
android:layout_height="45dp"
android:layout_weight="1"
android:text="#string/key_tan"/>
<Button
android:id="#+id/graphY"
android:layout_width="0dp"
android:layout_height="45dp"
android:layout_weight="1"
android:text="#string/button_y"/>
<Button
android:id="#+id/graphFour"
android:layout_width="0dp"
android:layout_height="45dp"
android:layout_weight="1"
android:text="#string/key_four"/>
<Button
android:id="#+id/graphFive"
android:layout_width="0dp"
android:layout_height="45dp"
android:layout_weight="1"
android:text="#string/key_five"/>
<Button
android:id="#+id/graphSix"
android:layout_width="0dp"
android:layout_height="45dp"
android:layout_weight="1"
android:text="#string/key_six"/>
<Button
android:id="#+id/graphSum"
android:layout_width="0dp"
android:layout_height="45dp"
android:layout_weight="1"
android:layout_gravity="center_horizontal"
android:drawableBottom="#drawable/ic_add"/>
</LinearLayout>
<LinearLayout
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="45dp"
android:orientation="horizontal">
<Button
android:textAllCaps="false"
android:id="#+id/graphAsin"
android:layout_width="0dp"
android:layout_height="45dp"
android:layout_weight="2"
android:text="#string/key_asin"/>
<Button
android:textAllCaps="false"
android:id="#+id/graphSin"
android:layout_width="0dp"
android:layout_height="45dp"
android:layout_weight="1"
android:text="#string/key_sin"/>
<Button
android:id="#+id/graphModule"
android:layout_width="0dp"
android:layout_height="45dp"
android:layout_weight="1"
android:text="#string/key_module"/>
<Button
android:id="#+id/graphSeven"
android:layout_width="0dp"
android:layout_height="45dp"
android:layout_weight="1"
android:text="#string/key_seven"/>
<Button
android:id="#+id/graphEight"
android:layout_width="0dp"
android:layout_height="45dp"
android:layout_weight="1"
android:text="#string/key_eight"/>
<Button
android:id="#+id/graphNine"
android:layout_width="0dp"
android:layout_height="45dp"
android:layout_weight="1"
android:text="#string/key_nine"/>
<Button
android:id="#+id/graphMinus"
android:layout_width="0dp"
android:layout_height="45dp"
android:layout_weight="1"
android:layout_gravity="center_horizontal"
android:drawableBottom="#drawable/ic_minus"/>
</LinearLayout>
<LinearLayout
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="45dp"
android:orientation="horizontal">
<Button
android:textAllCaps="false"
android:id="#+id/graphAcot"
android:layout_width="0dp"
android:layout_height="45dp"
android:layout_weight="2"
android:text="#string/key_acot"/>
<Button
android:textAllCaps="false"
android:id="#+id/graphCot"
android:layout_width="0dp"
android:layout_height="45dp"
android:layout_weight="1"
android:text="#string/key_cot"/>
<Button
android:textAllCaps="false"
android:id="#+id/graphLn"
android:layout_width="0dp"
android:layout_height="45dp"
android:layout_weight="1"
android:text="#string/key_ln"/>
<Button
android:textAllCaps="false"
android:id="#+id/graphLog"
android:layout_width="0dp"
android:layout_height="45dp"
android:layout_weight="1"
android:text="#string/key_log"/>
<Button
android:textAllCaps="false"
android:id="#+id/graphLg"
android:layout_width="0dp"
android:layout_height="45dp"
android:layout_weight="1"
android:text="#string/key_lg"/>
<Button
android:id="#+id/graphZero"
android:layout_width="0dp"
android:layout_height="45dp"
android:layout_weight="1"
android:text="#string/key_zero"/>
<Button
android:id="#+id/graphDivizion"
android:layout_width="0dp"
android:layout_height="45dp"
android:layout_weight="1"
android:text="#string/divizion"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="5dp">
</LinearLayout>
</LinearLayout>
i make a math keyboard inside my programm.
Than i did editText, where will add a text from my keyboard
<TableLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TableRow>
<Button
android:theme="#style/Widget.AppCompat.Button.Colored"
android:layout_weight="1"
android:gravity="center"
android:id="#+id/buttonClick"
android:layout_width="10dp"
android:layout_height="45dp"
android:text="#string/Calc"/>
<EditText
android:layout_weight="1"
android:id="#+id/editGraphText"
android:layout_width="200dp"
android:layout_height="45dp"
android:inputType="textPersonName"
android:text=""/>
<Button
android:id="#+id/buttonClear"
android:layout_width="45dp"
android:layout_height="45dp"
android:gravity="center"
android:text="#string/Clear" />
</TableRow>
</TableLayout>
Then i need to hide my keyboard and open it again.
When i hide my keyboard and open it again, my code does't work.
I checked buttons. Button is work, but editText did't change.
Here code on java
keyBoard = (LinearLayout) view.findViewById(R.id.keyBoard);
editText = (EditText) view.findViewById(R.id.editGraphText);
editText.setInputType(InputType.TYPE_NULL);
buttonSin = (Button) view.findViewById(R.id.graphSin);
buttonCos = (Button) view.findViewById(R.id.graphCos);
buttonTan = (Button) view.findViewById(R.id.graphTan);
buttonCot = (Button) view.findViewById(R.id.graphCot);
buttonAsin = (Button) view.findViewById(R.id.graphAsin);
buttonAcos = (Button) view.findViewById(R.id.graphAcos);
buttonAcot = (Button) view.findViewById(R.id.graphAcot);
buttonAtan = (Button) view.findViewById(R.id.graphAtan);
buttonMultiply = (Button) view.findViewById(R.id.graphMultiply);
buttonSum = (Button) view.findViewById(R.id.graphSum);
buttonDegree = (Button) view.findViewById(R.id.graphDegree);
buttonMinus = (Button) view.findViewById(R.id.graphMinus);
buttonDivizion = (Button) view.findViewById(R.id.graphDivizion);
buttonLog = (Button) view.findViewById(R.id.graphLog);
buttonLg = (Button) view.findViewById(R.id.graphLg);
buttonPi = (Button) view.findViewById(R.id.graphPi);
buttonE = (Button) view.findViewById(R.id.graphE);
buttonLeftBracket = (Button) view.findViewById(R.id.graphLeftBracket);
buttonLeftSquareBracket = (Button) view.findViewById(R.id.graphLeftSquareBracket);
buttonRightSquareBracket = (Button) view.findViewById(R.id.graphRightSquareBracket);
buttonRightBracket = (Button) view.findViewById(R.id.graphRightBracket);
buttonOne = (Button) view.findViewById(R.id.graphOne);
buttonTwo = (Button) view.findViewById(R.id.graphTwo);
buttonThree = (Button) view.findViewById(R.id.graphThree);
buttonFour = (Button) view.findViewById(R.id.graphFour);
buttonFive = (Button) view.findViewById(R.id.graphFive);
buttonSix = (Button) view.findViewById(R.id.graphSix);
buttonSeven = (Button) view.findViewById(R.id.graphSeven);
buttonEight = (Button) view.findViewById(R.id.graphEight);
buttonNine = (Button) view.findViewById(R.id.graphNine);
buttonZero = (Button) view.findViewById(R.id.graphZero);
buttonModule = (Button) view.findViewById(R.id.graphModule);
buttonX = (Button) view.findViewById(R.id.graphX);
buttonY = (Button) view.findViewById(R.id.graphY);
buttonLn = (Button) view.findViewById(R.id.graphLn);
buttonClear = (Button) view.findViewById(R.id.graphDelete);
editText.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
keyBoard.setVisibility(View.VISIBLE);
}
});
buttonSin.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
finalText += "sin(";
editText.setText(finalText);
}
});
buttonCos.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
finalText += "cos(";
editText.setText(finalText);
}
});
buttonTan.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
finalText += "tan(";
editText.setText(finalText);
}
});
buttonCot.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
finalText += "cot(";
editText.setText(finalText);
}
});
When i want to hide my keyboard i use this in my activity
#Override
public void onBackPressed() {
LinearLayout keyBoard = (LinearLayout) findViewById(R.id.keyBoard);
if (keyBoard.getVisibility() == View.INVISIBLE) {
Fragment fragment = null;
Class fragmentClass = null;
fragmentClass = GraphActivity.class;
try {
fragment = (Fragment) fragmentClass.newInstance();
} catch (Exception e) {
e.printStackTrace();
}
FragmentManager fragmentManager = getSupportFragmentManager();
fragmentManager.beginTransaction().replace(R.id.container, fragment).commit();
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
drawer.closeDrawer(GravityCompat.START);
} else {
keyBoard.setVisibility(View.INVISIBLE);
}
}
Other clickListener inside code, here is a part of code, i did't copy every clickListener.
How i can make to work my code?
I need to hide my keyboard and I want to open it again, but it did't work.
Where is my mistake?
I have problem with drawerLayout. in drawerLayout, i have two Linearlayouts. one is the main menu that shows directly, the otherone is active with drawer slide. when i slide the drawer menü i cant click the buttons. but when i remove the second linearLayout then the buttons in the drawer work. how can i solve it?
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/drawerLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=""
android:clickable="true"
android:contextClickable="true">
<LinearLayout
android:orientation="vertical"
android:layout_gravity="left|start"
android:background="#color/list_back"
android:layout_width="250dp"
android:layout_height="match_parent"
android:onClick="setContentView"
android:contextClickable="true"
android:clickable="true">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Ana Sayfa"
android:id="#+id/buttonAnaSayfa"
android:onClick="setContentView"
android:clickable="false"
android:contextClickable="false"
android:nestedScrollingEnabled="false" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Kalori Tablosu"
android:id="#+id/buttonKalori"
android:onClick="setContentView"
android:clickable="true"
android:contextClickable="true" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Glisemik İndeks Tablosu"
android:id="#+id/buttonGITablosu"
android:onClick="setContentView"
android:clickable="true"
android:contextClickable="true" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Vücut Kütle İndeksi"
android:id="#+id/buttonVucutKutle"
android:onClick="setContentView"
android:clickable="true"
android:contextClickable="true" />
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:foregroundGravity="center">
<ImageButton
android:layout_width="360dp"
android:layout_height="wrap_content"
android:id="#+id/imageButtonKaloriListesi"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:src="#drawable/kalori_listesi_button"
android:background="#null"
android:layout_marginTop="10dp"
android:foregroundGravity="center"
android:gravity="center"/>
<ImageButton
android:layout_width="360dp"
android:layout_height="wrap_content"
android:id="#+id/imageButtonGITablosu"
android:src="#drawable/gi_tablosu_button"
android:layout_below="#+id/imageButtonKaloriListesi"
android:layout_alignParentStart="true"
android:background="#null"
android:layout_marginTop="10dp"
android:foregroundGravity="center"
android:gravity="center"/>
<ImageButton
android:layout_width="360dp"
android:layout_height="wrap_content"
android:id="#+id/imageButtonBugunKaloriHesabi"
android:src="#drawable/bugun_kac_kalori_aldin_button"
android:background="#null"
android:layout_above="#+id/imageButtonVucutKutleIndeks"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
android:foregroundGravity="center"
android:gravity="center"/>
<ImageButton
android:layout_width="360dp"
android:layout_height="wrap_content"
android:id="#+id/imageButtonVucutKutleIndeks"
android:src="#drawable/vucut_kutle_indeksi_button"
android:background="#null"
android:layout_centerVertical="true"
android:layout_alignStart="#+id/imageButtonBugunKaloriHesabi"
android:layout_marginTop="10dp"
android:foregroundGravity="center"
android:gravity="center"/>
<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="test"
android:id="#+id/buttontest1"
android:layout_gravity="center_horizontal" />
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="230dp"
android:layout_gravity="center_horizontal"
android:id="#+id/ad"
android:layout_marginTop="40dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"></LinearLayout>
</LinearLayout>
here is my .java ;
package com.azelirbrevo.glisemikindeks
public class "" extends AppCompatActivity {
//DrawerLayout drawerLayout;
//ActionBarDrawerToggle toggle;
//CharSequence actionBarTitle, appTitle;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.firstaftersplash);
ImageButton ImageButtonKaloriListesi = (ImageButton) findViewById(R.id.imageButtonKaloriListesi);
ImageButton imageButtonGITablosu = (ImageButton) findViewById(R.id.imageButtonGITablosu);
ImageButton imageButtonVucutKutleIndeks = (ImageButton) findViewById(R.id.imageButtonVucutKutleIndeks);
ImageButton imageButtonBugunKaloriHesabi = (ImageButton) findViewById(R.id.imageButtonBugunKaloriHesabi);
ImageButtonKaloriListesi.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
Intent intent = new Intent(firstAfterSplash.this, KaloriListesi.class);
startActivity(intent);
}
});
imageButtonGITablosu.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
Intent intent = new Intent(firstAfterSplash.this, GITablosu.class);
startActivity(intent);
}
});
imageButtonVucutKutleIndeks.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
Intent intent = new Intent(firstAfterSplash.this, VucutKutleIndexHesaplama.class);
startActivity(intent);
}
});
imageButtonBugunKaloriHesabi.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
Intent intent = new Intent(firstAfterSplash.this, bugunKacKaloriAldim.class);
startActivity(intent);
}
});
//drawerLayout = (DrawerLayout) findViewById(R.id.drawerLayout);
//actionBarTitle = appTitle = getSupportActionBar().getTitle();
Button buttonAnasayfa = (Button) findViewById(R.id.buttonAnaSayfa);
Button buttonKalori = (Button) findViewById(R.id.buttonKalori);
Button buttonGı = (Button) findViewById(R.id.buttonGITablosu);
Button buttonVucutKutle = (Button) findViewById(R.id.buttonVucutKutle);
Button test = (Button) findViewById(R.id.buttontest1);
test.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
Intent intent = new Intent(firstAfterSplash.this, TEST.class);
startActivity(intent);
}
});
buttonAnasayfa.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
Toast.makeText(getApplicationContext(), "tiklandi", Toast.LENGTH_SHORT).show();
Intent intent = new Intent(firstAfterSplash.this, GITablosu.class);
startActivity(intent);
}
});
buttonKalori.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
Toast.makeText(getApplicationContext(), "tiklandi", Toast.LENGTH_SHORT).show();
Intent intent = new Intent(firstAfterSplash.this, GITablosu.class);
startActivity(intent);
}
});
buttonGı.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
Toast.makeText(getApplicationContext(), "tiklandi", Toast.LENGTH_SHORT).show();
Intent intent = new Intent(firstAfterSplash.this, GITablosu.class);
startActivity(intent);
}
});
buttonVucutKutle.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
Toast.makeText(getApplicationContext(), "tiklandi", Toast.LENGTH_SHORT).show();
Intent intent = new Intent(firstAfterSplash.this, GITablosu.class);
startActivity(intent);
}
});
}}
this is the design
You can create a application with Navigation drawer Activity here you can see custom layout inside drawer layout and inside layout you can set any type of widgets as button, TextView and any type what ever you want.
In xml file, my drawer menu items (LinearLayout and Buttons) were over my main LinearLayout. I just cut-paste it under the main LinearLayout and it helped.
here is the updated xml file of my project, hope will help someone.
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/drawerLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=""
android:clickable="true"
android:contextClickable="true">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:foregroundGravity="center">
<ImageButton
android:layout_width="360dp"
android:layout_height="wrap_content"
android:id="#+id/imageButtonKaloriListesi"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:src="#drawable/kalori_listesi_button"
android:background="#null"
android:layout_marginTop="10dp"
android:foregroundGravity="center"
android:gravity="center"/>
<ImageButton
android:layout_width="360dp"
android:layout_height="wrap_content"
android:id="#+id/imageButtonGITablosu"
android:src="#drawable/gi_tablosu_button"
android:layout_below="#+id/imageButtonKaloriListesi"
android:layout_alignParentStart="true"
android:background="#null"
android:layout_marginTop="10dp"
android:foregroundGravity="center"
android:gravity="center"/>
<ImageButton
android:layout_width="360dp"
android:layout_height="wrap_content"
android:id="#+id/imageButtonBugunKaloriHesabi"
android:src="#drawable/bugun_kac_kalori_aldin_button"
android:background="#null"
android:layout_above="#+id/imageButtonVucutKutleIndeks"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
android:foregroundGravity="center"
android:gravity="center"/>
<ImageButton
android:layout_width="360dp"
android:layout_height="wrap_content"
android:id="#+id/imageButtonVucutKutleIndeks"
android:src="#drawable/vucut_kutle_indeksi_button"
android:background="#null"
android:layout_centerVertical="true"
android:layout_alignStart="#+id/imageButtonBugunKaloriHesabi"
android:layout_marginTop="10dp"
android:foregroundGravity="center"
android:gravity="center"/>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="230dp"
android:layout_gravity="center_horizontal"
android:id="#+id/ad"
android:layout_marginTop="40dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"></LinearLayout>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_gravity="left|start"
android:layout_width="250dp"
android:layout_height="match_parent"
android:onClick="setContentView"
android:contextClickable="true"
android:clickable="true"
android:background="#85c7f1">
<Button
android:layout_width="fill_parent"
android:layout_height="50dp"
android:id="#+id/ButtonDrawerAnaSayfa"
android:background="#null"
android:layout_gravity="left"
android:gravity="left"/>
<Button
android:layout_width="fill_parent"
android:layout_height="50dp"
android:id="#+id/ButtonDrawerKalori"
android:background="#null"
android:layout_gravity="left"
android:gravity="left"/>
<Button
android:layout_width="fill_parent"
android:layout_height="50dp"
android:id="#+id/ButtonDrawerGI"
android:background="#null"
android:layout_gravity="left"
android:gravity="left"/>
<Button
android:layout_width="fill_parent"
android:layout_height="50dp"
android:id="#+id/ButtonDrawerVucutKutle"
android:background="#null"
android:layout_gravity="left"
android:gravity="left"/>
</LinearLayout>
public class AddActivity extends Activity implements OnClickListener{
String[] info = new String[11];
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.add_layout);
}
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
TextView keyString = (TextView)findViewById(R.id.keyString);
TextView site1 = (TextView)findViewById(R.id.site1);
TextView site2 = (TextView)findViewById(R.id.site2);
TextView site3 = (TextView)findViewById(R.id.site3);
ImageButton submit = (ImageButton)findViewById(R.id.submit);
ImageButton add1 = (ImageButton)findViewById(R.id.add1);
ImageButton add2 = (ImageButton)findViewById(R.id.add2);
ImageButton add3 = (ImageButton)findViewById(R.id.add3);
submit.setOnClickListener((OnClickListener) this);
add1.setOnClickListener((OnClickListener) this);
add2.setOnClickListener((OnClickListener) this);
add3.setOnClickListener((OnClickListener) this);
int id = v.getId();
switch(id){
case R.id.submit:{
submitEntry(info);
break;
}
case R.id.add1:{
add2.setVisibility(View.VISIBLE);
site2.setVisibility(View.VISIBLE);
break;
}
}
}
}
This is the code.
<?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="vertical" >
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/key_string"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:visibility="invisible" />
<EditText
android:id="#+id/keyString"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:visibility="invisible" />
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/site_string"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/textView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:visibility="invisible" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<ImageButton
android:id="#+id/add1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_action_new" />
<EditText
android:id="#+id/site1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/url_hint"
android:textAppearance="?android:attr/textAppearanceLarge" />
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:visibility="invisible" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<ImageButton
android:id="#+id/add2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_action_new"
android:visibility="invisible" />
<EditText
android:id="#+id/site2"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:text="#string/url_hint"
android:textAppearance="?android:attr/textAppearanceLarge"
android:visibility="invisible" />
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:visibility="invisible" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<ImageButton
android:id="#+id/add3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_action_new"
android:visibility="invisible" />
<EditText
android:id="#+id/site3"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:text="#string/url_hint"
android:visibility="invisible"
android:textAppearance="?android:attr/textAppearanceLarge" />
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:visibility="invisible" />
<Button
android:id="#+id/submit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="#string/submit_buttom" />
</LinearLayout>
</ScrollView>
</LinearLayout>
And this is the XML. The add1, add2, add3 and submit ImageButtons are all in a ScrollView.
When I press the add1 ImageButton, I want the add2 and site2 ImageButtons to become visible but instead, it throws the following error.
Motion event has invalid pointer count 0; value must be between 1 and 16.
What am I doing wrong?
PS: All the findViewById() calls are in the onClick() method because a NullPointerExeption is thrown if I call them in the onCreate().
Those findViewByIdcalls in onClickdon't make sense. Not sure why you are getting a null pointer exception calling them in onCreate.onClick is never called in this instance because nothing in the creation of the Activity is assigning the buttons to look at your onClick method; the buttons will default to having no listener assigned. It also doesn't look like a good idea to use the Activity as the onClickListener as well.
Your code should look something like this:
public class AddActivity extends Activity {
// https://source.android.com/source/code-style.html
// info -> mInfo; non-public, non-static field!
String[] mInfo = new String[11];
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.add_layout);
TextView keyString = (TextView)findViewById(R.id.keyString);
TextView site1 = (TextView)findViewById(R.id.site1);
TextView site2 = (TextView)findViewById(R.id.site2);
TextView site3 = (TextView)findViewById(R.id.site3);
Button submit = (Button)findViewById(R.id.submit);
ImageButton add1 = (ImageButton)findViewById(R.id.add1);
ImageButton add2 = (ImageButton)findViewById(R.id.add2);
ImageButton add3 = (ImageButton)findViewById(R.id.add3);
add1.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
add2.setVisibility(View.VISIBLE);
site2.setVisibility(View.VISIBLE);
}
});
submit.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
submitEntry(mInfo);
}
});
}
The findViewById() calls and especially the setOnClickListener() calls should have been inside the onCreate(). With setOnClickListener() inside the onClick() i doubt the onClick was ever called.
We would need more logs to find the exact issue.
I have added an imageswitcher to my register fragment, when the user select his/her gender the image changes but the image shown is too big and I cant scale it. I am using a scrollview and it is not good that the Imageswitcher is bigger than screen. I tried using smaller images but the result is same. Here is my XML:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/registerbackground"
android:fillViewport="true" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:gravity="center"
android:orientation="horizontal" >
<TextView
android:id="#+id/kayit_kayit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/register"
android:textColor="#FFFFFFFF"
android:textSize="20sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:gravity="center"
android:orientation="horizontal" >
<EditText
android:id="#+id/kayit_ad"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginLeft="50dp"
android:layout_marginRight="50dp"
android:hint="#string/hintAd"
android:inputType="textNoSuggestions"
android:textColor="#FFFFFFFF" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal" >
<EditText
android:id="#+id/kayit_soyad"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginLeft="50dp"
android:layout_marginRight="50dp"
android:hint="#string/hintSoyad"
android:inputType="textNoSuggestions"
android:textColor="#FFFFFFFF" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal" >
<EditText
android:id="#+id/kayit_email"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginLeft="50dp"
android:layout_marginRight="50dp"
android:hint="#string/hintEmail"
android:inputType="textEmailAddress"
android:textColor="#FFFFFFFF" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal" >
<RadioGroup
android:id="#+id/radioGroup1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<RadioButton
android:id="#+id/radio0"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="false"
android:text="#string/kayitKiz"
android:textColor="#FFFFFFFF" />
<RadioButton
android:id="#+id/radio1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="false"
android:text="#string/kayitErkek"
android:textColor="#FFFFFFFF" />
</RadioGroup>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal">
<ImageSwitcher
android:id="#+id/cinsiyetSwitcher"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
</ImageSwitcher>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal">
<EditText
android:id="#+id/kayit_kelime1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginLeft="50dp"
android:hint="#string/hintKelimeler1"
android:inputType="textNoSuggestions"
android:textColor="#FFFFFFFF"/>
<EditText
android:id="#+id/kayit_kelime2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="#string/hintKelimeler2"
android:inputType="textNoSuggestions"
android:textColor="#FFFFFFFF"/>
<EditText
android:id="#+id/kayit_kelime3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginRight="50dp"
android:hint="#string/hintKelimeler3"
android:inputType="textNoSuggestions"
android:textColor="#FFFFFFFF"/>
</LinearLayout>
</LinearLayout>
</ScrollView>
and the code for the imageswitcher:
....
cinsiyetSwitcher = (ImageSwitcher) rootView.findViewById(R.id.cinsiyetSwitcher);
cinsiyetSwitcher.setFactory(new ViewFactory() {
#Override
public View makeView() {
ImageView imageView = new ImageView(getActivity());
imageView.setScaleType(ImageView.ScaleType.CENTER);
imageView.setLayoutParams(new ImageSwitcher.LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT));
return imageView;
}
});
kizRadio = (RadioButton) rootView.findViewById(R.id.radio0);
erkekRadio = (RadioButton) rootView.findViewById(R.id.radio1);
kizRadio.setOnClickListener( new View.OnClickListener() {
public void onClick(View v)
{
degistir1(v);
}
});
erkekRadio.setOnClickListener( new View.OnClickListener() {
public void onClick(View v)
{
degistir2(v);
}
});
....
...
public void degistir1(View view)
{
Animation in = AnimationUtils.loadAnimation(getActivity(),
android.R.anim.slide_in_left);
Animation out = AnimationUtils.loadAnimation(getActivity(),
android.R.anim.slide_out_right);
cinsiyetSwitcher.setInAnimation(in);
cinsiyetSwitcher.setOutAnimation(out);
cinsiyetSwitcher.setImageResource(R.drawable.kari);
}
public void degistir2(View view)
{
Animation in = AnimationUtils.loadAnimation(getActivity(),
android.R.anim.slide_out_right);
Animation out = AnimationUtils.loadAnimation(getActivity(),
android.R.anim.slide_in_left);
cinsiyetSwitcher.setInAnimation(out);
cinsiyetSwitcher.setOutAnimation(in);
cinsiyetSwitcher.setImageResource(R.drawable.adam);
}
I have several Views, text views, and a button that have the android:visibility="invisible" attribute. My goal is to click a button that resides above these 'invisible' widgets, so that these widgets will become visible. I created another java class called 'VisibilityActivity.java" and tried the following method. But for some reason when I run the app, the button doesn't do anything. I don't know what I'm missing.
Here's the code:
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class VisibilityActivity extends Activity {
private View mVictim;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.new_property3);
mVictim = findViewById(R.id.horizontalRule1);
mVictim = findViewById(R.id.TextView03);
mVictim = findViewById(R.id.horizontalRule2);
Button submitRating = (Button) findViewById(R.id.submitRatingButton);
submitRating.setOnClickListener(mVisibleListener);
}
OnClickListener mVisibleListener = new OnClickListener() {
public void onClick(View v) {
mVictim.setVisibility(View.INVISIBLE);
}
};
}
Here is the xml:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/custom_background"
android:isScrollContainer="true"
android:orientation="vertical"
android:paddingTop="10dp" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_gravity="center"
android:text="#string/ratingsInfo"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#color/black1" />
<View
android:layout_width="fill_parent"
android:layout_height="2dp"
android:background="#color/black1"
android:layout_marginLeft="2dp"
android:layout_marginRight="2dp"
android:layout_marginBottom="5dp" />
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:text="#string/yourRating"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/black1" />
<RatingBar
android:id="#+id/ratingBar1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginBottom="10dp" />
<Button
android:id="#+id/submitRatingButton"
android:layout_width="275dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginBottom="10dp"
android:background="#drawable/custom_button"
android:text="#string/submitRating"
android:textColor="#color/black1" />
<View
android:id="#+id/horizontalRule1"
android:layout_width="fill_parent"
android:layout_height="2dp"
android:background="#color/black1"
android:layout_marginLeft="2dp"
android:layout_marginRight="2dp"
android:layout_marginBottom="5dp"
android:visibility="invisible" />
<TextView
android:id="#+id/TextView03"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_gravity="center"
android:text="#string/summaryInfo"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#color/black1"
android:visibility="invisible" />
<View
android:id="#+id/horizontalRule2"
android:layout_width="fill_parent"
android:layout_height="2dp"
android:background="#color/black1"
android:layout_marginLeft="2dp"
android:layout_marginRight="2dp"
android:layout_marginBottom="5dp"
android:visibility="invisible" />
<TextView
android:id="#+id/TextView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:text="#string/ourRating"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/black1"
android:visibility="invisible" />
<RatingBar
android:id="#+id/ratingBar2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:stepSize=".01"
android:layout_marginBottom="10dp"
android:visibility="invisible" />
<TextView
android:id="#+id/TextView02"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:text="#string/overallRating"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/black1"
android:visibility="invisible" />
<RatingBar
android:id="#+id/ratingBar3"
android:color="#color/black1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:stepSize=".01"
android:layout_marginBottom="40dp"
android:visibility="invisible" />
<Button
android:id="#+id/saveContinueButton3"
android:layout_width="275dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginBottom="15dp"
android:background="#drawable/custom_button"
android:text="#string/saveContinue"
android:textColor="#color/black1"
android:onClick="onSaveAndContinue3Clicked"
android:visibility="invisible" />
</LinearLayout>
</ScrollView>
Thanks. Help would be greatly appreciated!
I am updating user936414's answer.
OnClickListener mVisibleListener = new OnClickListener() {
public void onClick(View v) {
if( mText.getVisibility() == View.INVISIBLE )
mText.setVisibility(View.VISIBLE);
else
mText.setVisibility(View.INVISIBLE);
if( mRule1.getVisibility() == View.INVISIBLE )
mRule1.setVisibility(View.VISIBLE);
else
mRule1.setVisibility(View.INVISIBLE);
if( mRule2.getVisibility() == View.INVISIBLE )
mRule2.setVisibility(View.VISIBLE);
else
mRule2.setVisibility(View.INVISIBLE);
}
};
Also you might want to experiment with View.GONE.
findViewById(R.id.ratingBar3).setVisibility(View.VISIBLE);
findViewById(R.id.saveContinueButton3).setVisibility(View.VISIBLE);
you made it invisible view invisible again.. try the above code
Try
public class VisibilityActivity extends Activity {
private TextView mText;
private View mRule1, mRule2;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.new_property3);
mText= (TextView)findViewById(R.id.horizontalRule1);
mRule1 = findViewById(R.id.TextView03);
mRule2 = findViewById(R.id.horizontalRule2);
Button submitRating = (Button) findViewById(R.id.submitRatingButton);
submitRating.setOnClickListener(mVisibleListener);
}
OnClickListener mVisibleListener = new OnClickListener() {
public void onClick(View v) {
mText.setVisibility(View.VISIBLE);
mRule1.setVisibility(View.VISIBLE);
mRule2.setVisibility(View.VISIBLE);
}
};
}
Button submitRating = (Button) findViewById(R.id.submitRatingButton);
submitRating.setOnClickListener(new View.onClickListener)
{
#Override
public void onClick(View v)
{
//Insert your code here
}
}