Followed example to the letter. When I try to use a custom button via a custom.xml, emulator crashes with a Java error - inflating class android.widget.Button.
import android.os.Bundle;
import android.content.Intent;
import android.app.Activity;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class MasterActivity extends Activity {
Button uccBtn, tipBtn;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_master);
uccBtn = (Button) findViewById(R.id.button1);
tipBtn = (Button) findViewById(R.id.button2);
uccBtn.setOnClickListener (uccApp);
tipBtn.setOnClickListener (tipApp);
custom.xml
<?xml version="1.0" encoding="UTF-8"?>
<Selector xmlns:android="http://schemas.android.com/apk/res/android"
>
<item android:state_pressed="true" android:drawable="#drawable/btn_ecolab_selected"></item>
<item android:state_focused="true"
android:drawable="#drawable/btn_ecolab_highlight"></item>
<item android:drawable="#drawable/btn_ecolab"></item>
</Selector>
activity_main.xml
<?xml version="1.0" encoding="UTF-8"?>
<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:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:background ="#ffffcc"
tools:context=".MasterActivity" >
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/button2"
android:layout_alignParentTop="true"
android:layout_marginTop="23dp"
android:text="#string/button1" android:typeface="serif"
android:background="#drawable/custom"
/>
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:text="#string/version"
android:textAppearance="?android:attr/textAppearanceSmall" />
<Button
android:id="#+id/button10"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/button1"
android:layout_below="#+id/button1"
android:layout_marginTop="56dp"
android:text="#string/button10" android:typeface="serif"
android:background="#drawable/custom" />
<Button
android:id="#+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/button10"
android:layout_centerHorizontal="true"
android:layout_marginTop="59dp"
android:text="#string/button2" android:typeface="serif"
android:background="#drawable/custom"
/>
</RelativeLayout>
If I reference just the button by name (btn_ecolab), it works fine, just no animation of the buttons when pressed or selected. I've tried it with a LinearLayout to make sure that the Relitavelayout was not the problem. The custom buttons are in my Res/drawable-hpdi folder. Also tried copies of buttons and custom.xml in the -mdpi, -xhdpi and -xxhdpi. Tried without #string assignments.
try this one.
uccBtn = (Button) findViewById(R.id.button1);
tipBtn = (Button) findViewById(R.id.button2);
uccBtn.setOnClickListener (new OnClickListener() {
#Override
public void onClick(View v) {
//your code is here
}
});
make one folder drawable in res folder put your custom.xml
I am using this way and work great.
Related
I've attempting to upgrade my Android project to compile with Android 5.0. I was using the appcompat-v7 library successfully before this. Now using ActionBarActivity and Theme.AppCompat causes the views in my fragment layout not to render or not to be visible. If I change it back to Activity and remove the appcompat theme, the views are visible again. Can anyone point out the configuration that I'm doing wrong? My Eclipse project is compiling with Android 5.0, Private Libraries of android-support-v4.jar and android-support-v7-appcompat.jar. Under Android dependencies is android-support-v7-appcompat.jar.
And I have the following code:
in AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?><!DOCTYPE something>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mycompany.ctest"
android:versionCode="33"
android:versionName="1.4.0" >
<uses-sdk android:minSdkVersion="7" android:targetSdkVersion="18"/>
<application
android:icon="#drawable/ic_launcher"
android:label="My App"
android:allowBackup="true" >
<activity
android:name=".MyActivity"
android:theme="#style/Theme.AppCompat">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
In fragment_layout.xml:
<?xml version="1.0" encoding="utf-8"?><!DOCTYPE something>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal" >
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Nothing here"
android:textColor="#color/blue" >
</TextView>
</LinearLayout>
In MyActivity.java:
package com.mycompany.ctest;
import android.app.FragmentManager;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
public class MyActivity extends ActionBarActivity {
private FragmentManager mFM;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mFM = getFragmentManager();
mFM.beginTransaction()
.add(android.R.id.content, new MyFragment(),"frag")
.commit();
}
}
And in MyFragment.java:
package com.mycompany.ctest;
import android.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
public class MyFragment extends Fragment {
#Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); }
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup group, Bundle saved) {
return inflater.inflate(R.layout.fragment_layout,group,false);
}
}
EDIT: LogCat shows
12-13 10:10:09.709: E/ResourceType(1013): Style contains key with bad entry: 0x01010479
Although I think that must be irrelevant because if I add an Activity layout with a static fragment loaded instead of using the Fragment Manager, my view becomes visible. And I still get the Style contains key with bad entry message.
I finally added an activity layout with a blank frame layout with id.
activity_layout.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/fragment_container"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
Then used that id when adding fragments to the activity with .add or .replace instead of using android.R.id.content.
setContentView(R.layout.activity_layout);
getSupportFragmentManager().beginTransaction()
.add(R.id.fragment_container,new MyFragment(), "frag")
.commit();
I still don't know why that works and why android.R.id.content was not working.
Try importing from support library instead of just "import android.app.Fragment;" ...hope this might help
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
I'm testing out the Android Kit Kat transition feature. When the transition happens, the margins of the root layout are getting padded. I find this behavior strange.
The source
public class MainActivity extends ActionBarActivity {
Button btn;
TextView txt;
#TargetApi(Build.VERSION_CODES.KITKAT)
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
txt = (TextView)findViewById(R.id.text);
btn = (Button)findViewById(R.id.btn);
btn.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
ViewGroup root = (ViewGroup)findViewById(R.id.root);
Scene scene = Scene.getSceneForLayout(root, R.layout.activity_main2, MainActivity.this);
TransitionManager.go(scene);
}
});
}
...
}
activity_main.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:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:paddingBottom="#dimen/activity_vertical_margin"
android:id="#+id/root"
tools:context="com.sebouh00.test.scenes.MainActivity">
<Button android:id="#+id/btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Click me"
android:layout_marginBottom="12dp"/>
<TextView
android:id="#+id/text"
android:layout_below="#id/btn"
android:text="#string/hello_world"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textSize="18dp"/>
</RelativeLayout>
activity_main2.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:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:paddingBottom="#dimen/activity_vertical_margin"
android:id="#+id/root"
tools:context="com.sebouh00.test.scenes.MainActivity">
<Button android:id="#+id/btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Click me"
android:layout_marginBottom="12dp"/>
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/btn"
android:id="#+id/img"
android:src="#drawable/flag"
android:layout_marginBottom="12dp"/>
<TextView
android:id="#+id/text"
android:layout_below="#id/img"
android:text="#string/hello_world"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textSize="18dp"/>
</RelativeLayout>
Results in this unless I remove the paddings from activity_main2.xml
Any ideas why?
It's because the View produced by inflating activity_main2 gets inserted into the Scene's root, i.e. your R.id.root RelativeLayout, so the padding from R.id.root is still applied.
I followed the full instructions on http://developer.android.com/training/basics/firstapp/creating-project.html multiple times and have been unable to start an activity. The app basically has a text field and send button. When I enter text in the text field and hit the send button, another activity should be started. However, with my current code, hitting the send button does nothing.
MySecondApp/src/MainActivity.java
package com.example.mysecondapp;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.widget.EditText;
public class MainActivity extends Activity {
public final static String EXTRA_MESSAGE = "com.example.mysecondapp.MESSAGE";
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
/** Called when the user clicks the Send button */
public void sendMessage(View view) {
Intent intent = new Intent(this, DisplayMessageActivity.class);
EditText editText = (EditText) findViewById(R.id.edit_message);
String message = editText.getText().toString();
intent.putExtra(EXTRA_MESSAGE, message);
startActivity(intent);
}
}
MySecondApp/src/DisplayMessageActivity.java
package com.example.mysecondapp;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.NavUtils;
import android.view.MenuItem;
import android.widget.TextView;
public class DisplayMessageActivity extends Activity {
#SuppressLint("NewApi")
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Get the message from the intent
Intent intent = getIntent();
String message = intent.getStringExtra(MainActivity.EXTRA_MESSAGE);
// Create the text view
TextView textView = new TextView(this);
textView.setTextSize(40);
textView.setText(message);
// Set the text view as the activity layout
setContentView(textView);
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
NavUtils.navigateUpFromSameTask(this);
return true;
}
return super.onOptionsItemSelected(item);
}
}
MySecondApp/res/layout/activity_main.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:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<EditText android:id="#+id/edit_message"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:hint="#string/edit_message" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/button_send" />
android:onClick="sendMessage" />
</LinearLayout>
MySecondApp/res/layout/activity_display_message.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: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=".DisplayMessageActivity" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/hello_world" />
</RelativeLayout>
MySecondApp/res/values/strings.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Safe\'s First App</string>
<string name="edit_message">Enter a message</string>
<string name="button_send">Send</string>
<string name="action_settings">Settings</string>
<string name="title_activity_main">MainActivity</string>
<string name="title_activity_display_message">My Message</string>
<string name="hello_world">Hello world!</string>
</resources>
MySecondApp/AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.mysecondapp"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.mysecondapp.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.example.mysecondapp.DisplayMessageActivity"
android:label="#string/title_activity_display_message"
android:parentActivityName="com.example.mysecondapp.MainActivity" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.example.mysecondapp.MainActivity" />
</activity>
</application>
</manifest>
Your problem is in the xml for your first activity. You have two terminating characters in the Button. Remove the /> after your android:text line.
Change you xml:
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/button_send" />
android:onClick="sendMessage" />
to:
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/button_send"
android:onClick="sendMessage" />
And also, I think you should reference your button in the onCreate method.
You can also try to change your code to:
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
public class Main extends Activity {
public final static String EXTRA_MESSAGE = "com.example.mysecondapp.MESSAGE";
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button yourButton = (Button) findViewById(R.id.yourid);
yourButton.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
Intent intent = new Intent(Main.this, YourSecondActivity.class);
EditText editText = (EditText) findViewById(R.id.yourEditText);
String message = editText.getText().toString();
intent.putExtra(EXTRA_MESSAGE, message);
startActivity(intent);
}
});
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
And Change your xml from:
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/button_send" />
android:onClick="sendMessage" />
To:
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/button_send"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/button_send" />
android:onClick="sendMessage" />
See how the last line is black? That's because you ended the button tag twice with />
So take the closing tag away on the second last line: android:text="#string/button_send"
and your code would be:
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/button_send"
android:onClick="sendMessage" />
When locating the onClick property and select sendMessage [MainActivity] from the drop-down list, at .xml file: android:onClick="sendMessage (MainActivity)".
Delete "(MainActivity)":
So, at .xml file: android:onClick="sendMessage"
And run the app again!
I am using this code
package com.example.tabs;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.widget.TabHost;
import android.widget.TabHost.TabSpec;
public class MainActivity extends Activity {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TabHost tabHost=(TabHost)findViewById(R.id.tabHost);
tabHost.setup();
TabSpec spec1=tabHost.newTabSpec("Sími");
spec1.setContent(R.id.Sími);
spec1.setIndicator("Sími");
TabSpec spec2=tabHost.newTabSpec("Sms");
spec2.setIndicator("Sms");
spec2.setContent(R.id.Sms);
TabSpec spec3=tabHost.newTabSpec("Net");
spec3.setIndicator("Net");
spec3.setContent(R.id.Net);
TabSpec spec4=tabHost.newTabSpec("Greina");
spec4.setIndicator("Greina");
spec4.setContent(R.id.Greina);
tabHost.addTab(spec1);
tabHost.addTab(spec2);
tabHost.addTab(spec3);
tabHost.addTab(spec4);
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
}
with this xml file
<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/tabHost"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<TabWidget
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#android:id/tabs"
/>
<FrameLayout
android:id="#android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="match_parent" >
<LinearLayout
android:id="#+id/Sími"
android:layout_width="fill_parent"
android:layout_height="340dp"
android:orientation="vertical"
android:paddingTop="60px" >
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/Sms"
android:orientation="vertical"
android:paddingTop="60px"
>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/Net"
android:orientation="vertical"
android:paddingTop="60px"
>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/Greina"
android:orientation="vertical"
android:paddingTop="60px"
>
</LinearLayout>
</FrameLayout>
</TabHost>
I am new to android eclipse. I made 4 tabs(linearlayout) inside this tabview. But it is difficult to set the location on a button in one tab. How can i work with this 4 types of tabs like i am working with 4 xml files, is that possible ? How can i make the tabwidget smaller without the text not going away? , i hope this makes sense.
I my project i have a text view and button on my screen. On button click event i show custom dialog box (Dialog box content Edit text and a button). I put some data in dialog box edit text and click dialog box save button.
Now i want to show value of dialog edit text on screen text view on button click. How can i do this....
holder.list1.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
final TextView tv=(TextView)v.findViewById(R.id.textView3);
final Dialog dialog = new Dialog(activity);
dialog.setContentView(R.layout.customdailogfroaddmilk);
dialog.setTitle("Account");
// set the custom dialog components - text, image and button
final EditText text = (EditText) dialog.findViewById(R.id.editText1);
text.setText(tv.getText().toString());
Button save = (Button) dialog.findViewById(R.id.button1);
Button cancle = (Button) dialog.findViewById(R.id.button2);
save.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
dialog.dismiss();
tv.setText(text.getText().toString());
}
});
cancle.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
dialog.dismiss();
}
});
dialog.show();
}
});
on button(save) click event edittext(save) value not set in textview(tv)
?????.....
Create a layout in your layout folder and provide it as the View to a Dialog Object.
And for the example shown below, you need to have a TextView, a Button and EditText in that layout.
final Dialog dialog = new Dialog(context,
android.R.style.Theme_Translucent_NoTitleBar);
Window window = dialog.getWindow();
window.setLayout(ViewGroup.LayoutParams.FILL_PARENT,
ViewGroup.LayoutParams.FILL_PARENT);
dialog.setCancelable(true);
dialog.setCanceledOnTouchOutside(true);
dialog.setContentView(R.layout.xmlfile);
Button ok = (Button) dialog.findViewById(R.id.alert_ok_button);
TextView alert_title = (TextView ) dialog.findViewById(R.id.alert_title);
final EditText shelf_name_edit=(EditText)dialog.findViewById(R.id.shelf_name_edit_area);
alert_title.setText(title);
alert_title.setTextSize(20);
ok.setText("OK");
ok.setTextSize(20);
ok.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
dialog.cancel();
Log.i("EditText Value",shelf_name_edit.getEditableText().toString());
}
});
dialog.show();
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/RelativeLayout01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<Button android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:id="#+id/ClkBtn"
android:text="Click Me"></Button>
</RelativeLayout>
mydialog.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:background="#ffffff" android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
<TextView android:id="#+id/Tv1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="15px"
android:textColor="#6aa4cc"
android:text="Friendcaster for Facebook"
android:padding="10dip"
/>
<TextView android:id="#+id/Tv2"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:textSize="14px"
android:textColor="#android:color/black"
android:layout_below="#+id/Tv1"
android:textStyle="bold"
android:text="A , B , C , D and or 5 friend like your status "
android:padding="10dip"
/>
<View android:layout_height="15dip" android:layout_width="fill_parent"/>
<LinearLayout android:layout_height="wrap_content" android:layout_width="fill_parent"
android:orientation="horizontal" android:background="#d6d6d6"
android:layout_weight="3"
>
<LinearLayout android:layout_height="wrap_content" android:layout_width="wrap_content"
android:orientation="vertical"
android:gravity="left"
android:id="#+id/ll"
android:layout_weight="1" android:padding="5dip"
>
<ImageView android:src="#drawable/video"
android:layout_height="30dip" android:layout_width="30dip" android:layout_gravity="center_vertical|center_horizontal"
/>
<TextView android:layout_height="wrap_content" android:layout_width="wrap_content"
android:text="view" android:layout_gravity="center_vertical|center_horizontal"
android:textColor="#0388e5"
/>
</LinearLayout>
<View android:layout_height="match_parent" android:layout_width="1dip" android:background="#android:color/darker_gray"/>
<LinearLayout android:layout_height="wrap_content" android:layout_width="wrap_content"
android:orientation="vertical"
android:gravity="center"
android:layout_weight="1" android:padding="5dip"
>
<ImageView android:src="#drawable/chat"
android:layout_height="30dip" android:layout_width="30dip" android:layout_gravity="center_vertical|center_horizontal"
/>
<TextView android:layout_height="wrap_content" android:layout_width="wrap_content"
android:text="Reply" android:layout_gravity="center_vertical|center_horizontal"
android:textColor="#0388e5"
/>
</LinearLayout>
<View android:layout_height="match_parent" android:layout_width="1dip" android:background="#android:color/darker_gray"/>
<LinearLayout android:layout_height="wrap_content" android:layout_width="wrap_content"
android:orientation="vertical"
android:layout_weight="1" android:padding="5dip"
android:gravity="right"
>
<ImageView android:src="#drawable/cancel"
android:layout_height="30dip" android:layout_width="30dip" android:layout_gravity="center_vertical|center_horizontal"
/>
<TextView android:layout_height="wrap_content" android:layout_width="wrap_content"
android:text="Zip" android:layout_gravity="center_vertical|center_horizontal"
android:textColor="#0388e5"
/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
main.java
package com.example.cusmizepopup;
import android.os.Bundle;
import android.os.Message;
import android.app.Activity;
import android.app.Dialog;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.Toast;
public class MainActivity extends Activity {
Dialog myDialog;
Button myButton;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
myButton = (Button) findViewById(R.id.ClkBtn);
myButton.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v)
{
myDialog = new Dialog(MainActivity.this);
myDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
myDialog.setContentView(R.layout.mydialog);
//myDialog.setTitle("My Dialog");
myDialog.setCancelable(true);
//myDialog.setCancelable(true);
//myDialog.setCancelMessage("Are you Sure ? ")
LinearLayout button = (LinearLayout) myDialog.findViewById(R.id.ll);
button.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v)
{
//myDialog.dismiss();
Toast.makeText(getApplicationContext(), "hi", Toast.LENGTH_LONG).show();
}
});
myDialog.unregisterForContextMenu(myButton);
myDialog.show();
}
});
}
}