I'm working on showing emoji in popup window just like whatsapp from this library. I have created a popup window to show it in main activity. On click of button I made the following code
button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
View popUp = getLayoutInflater().inflate(R.layout.popup_item, null);
window = new PopupWindow(getApplicationContext());
window = new PopupWindow(popUp,LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT,true);
window.setAnimationStyle(android.R.style.Animation_Activity);
window.showAtLocation(popUp, Gravity.BOTTOM, 0, 0);
window.setFocusable(true);
window.setOutsideTouchable(true);
}
});
The popup_item contain the following
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:emojicon="http://schemas.android.com/apk/res-auto"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
tools:context="com.rockerhieu.emojicon.example.MainActivity$PlaceholderFragment" >
<com.rockerhieu.emojicon.EmojiconTextView
android:id="@+id/txtEmojicon"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
<com.rockerhieu.emojicon.EmojiconEditText
android:id="@+id/editEmojicon"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
emojicon:emojiconSize="28sp" />
<fragment
android:id="@+id/emojicons"
android:layout_width="fill_parent"
android:layout_height="220dp"
class="com.rockerhieu.emojicon.EmojiconsFragment" />
</LinearLayout>
it is showing the following error.
01-24 01:07:25.245: E/AndroidRuntime(5420): FATAL EXCEPTION: main
01-24 01:07:25.245: E/AndroidRuntime(5420): android.view.InflateException: Binary XML file line #21: Error inflating class fragment
01-24 01:07:25.245: E/AndroidRuntime(5420): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
01-24 01:07:25.245: E/AndroidRuntime(5420): at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
01-24 01:07:25.245: E/AndroidRuntime(5420): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
01-24 01:07:25.245: E/AndroidRuntime(5420): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
01-24 01:07:25.245: E/AndroidRuntime(5420): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
01-24 01:07:25.245: E/AndroidRuntime(5420): at com.example.popupemoji.MainActivity$1.onClick(MainActivity.java:29)
01-24 01:07:25.245: E/AndroidRuntime(5420): at android.view.View.performClick(View.java:4204)
01-24 01:07:25.245: E/AndroidRuntime(5420): at android.view.View$PerformClick.run(View.java:17355)
01-24 01:07:25.245: E/AndroidRuntime(5420): at android.os.Handler.handleCallback(Handler.java:725)
01-24 01:07:25.245: E/AndroidRuntime(5420): at android.os.Handler.dispatchMessage(Handler.java:92)
01-24 01:07:25.245: E/AndroidRuntime(5420): at android.os.Looper.loop(Looper.java:137)
01-24 01:07:25.245: E/AndroidRuntime(5420): at android.app.ActivityThread.main(ActivityThread.java:5041)
01-24 01:07:25.245: E/AndroidRuntime(5420): at java.lang.reflect.Method.invokeNative(Native Method)
01-24 01:07:25.245: E/AndroidRuntime(5420): at java.lang.reflect.Method.invoke(Method.java:511)
01-24 01:07:25.245: E/AndroidRuntime(5420): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
01-24 01:07:25.245: E/AndroidRuntime(5420): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
01-24 01:07:25.245: E/AndroidRuntime(5420): at dalvik.system.NativeStart.main(Native Method)
01-24 01:07:25.245: E/AndroidRuntime(5420): Caused by: java.lang.IllegalArgumentException: Binary XML file line #21: Duplicate id 0x7f080000, tag null, or parent id 0x0 with another fragment for com.rockerhieu.emojicon.EmojiconsFragment
01-24 01:07:25.245: E/AndroidRuntime(5420): at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:296)
01-24 01:07:25.245: E/AndroidRuntime(5420): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:676)
I found that the reason for it is the nested fragment. But don't know the solution for it. Please help on this. I really need to solve this. I'm new to android. Thanks.