I have been struggling with this for far too long. I want to display the nerd face http://emojipedia.org/nerd-face/ but am unsure how to go about it:
This is the current XML I have:
<com.rockerhieu.emojicon.EmojiconTextView
android:id="#+id/txtEmojicon1"
android:text=""
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="30dp"
android:textIsSelectable="true"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginLeft="44dp"
android:layout_marginStart="44dp" />
I have no idea what to place inside the android:text=""
Everything I place inside of the text="" comes out to not working
UPDATE THIS LIBRARY HAS BEEN DISCONTINUED BY THE OWNER UPDATE
see here : https://github.com/rockerhieu/emojicon
its pretty easy for you to implement any emoji type from Rockerheiu .
1.You will have to add the library as a module unlike adding it via the maven central Repository .
Once you are done adding module
Navigate to the library -> library\src\main\java\io\github\rockerhieu\emojicon\emoji and you edit the People.java File to get started on adding a new emoji code looks like this.
package io.github.rockerhieu.emojicon.emoji;
/**
* #author Hieu Rocker (rockerhieu#gmail.com)
*/
public class People {
public static final Emojicon[] DATA = new Emojicon[]{
Emojicon.fromCodePoint(0x1f604),
Emojicon.fromCodePoint(0x1f603),
Emojicon.fromCodePoint(0x1f600),
Emojicon.fromCodePoint(0x1f60a),
Emojicon.fromChar((char) 0x263a),
Emojicon.fromCodePoint(0x1f609),
Emojicon.fromCodePoint(0x1f60d),
Emojicon.fromCodePoint(0x1f618),
Related
I am trying to implement a WhatsApp Text Status like feature in a sample app. And I am using Android O's feature in support library for AutoResizeableTextView
<android.support.v7.widget.AppCompatEditText
android:id="#+id/status_edt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="start"
android:inputType="text"
android:maxLines="10"
android:textSize="60sp"
app:autoSizeMaxTextSize="60sp"
app:autoSizeMinTextSize="28sp"
app:autoSizeStepGranularity="3sp"
app:autoSizeTextType="uniform" />
But above code is not working in my case. Can anyone guide me through it ?
It is not supported with AppCompatEditText as seen in this AOSP code:
/**
* #return {#code true} if this TextView supports auto-sizing text to fit within its container.
*/
private boolean supportsAutoSizeText() {
// Auto-size only supports TextView and all siblings but EditText.
return !(mTextView instanceof AppCompatEditText);
}
Link to AOSP code:
https://github.com/aosp-mirror/platform_frameworks_support/blob/master/v7/appcompat/src/main/java/android/support/v7/widget/AppCompatTextViewAutoSizeHelper.java#L817
What I need to do is, give the app into hands of a non-programmer and make it simple for him to edit the xml and java files. To do that I thought maybe sending a simple request (such as, add product(name, description, price)) through some portal could edit the xml file and java file. For example, I need to repeat the similar code every time a new product request is posted:
activity_main.xml
<LinearLayout
android:id="#+id/hw5"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:padding="10dp"
android:clickable="true"
android:orientation="vertical">
<ImageView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:src="#mipmap/ic_launcher"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Hardware 5"
android:textColor="#000000"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="$-"/>
</LinearLayout>
MainActivity.java
LinearLayout hw5;
hw5 = (LinearLayout) findViewById(R.id.hw5);
hw5.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Intent hw5 = new Intent(MainActivity.this, Hw5.class);
startActivity(hw5);
}
});
Thanks!
What you might be looking for here is a domain-specific XML file paired with an appropriate XSL transformation. The XML file that the non-technical person would be editing would define the business entities, relationships with them and potential actions performed on them. The XSL transformation would convert this into application code at build time.
While this is not a common approach, it is rather robust. Keep in mind tho, that such an approach is difficult to maintain and requires that your business logic is mature enough before implementation.
I recently implemented Algolia on my app successfully just like the examples.
But the initial search takes about 5 to 7 seconds and I couldn't find a way to make it faster after checking the whole library code and documentation. After the initial search, search becomes very fast.
There is nothing unusual in my implementation but maybe you can see something that I don't. The following code is from the activity where I initialize Algolia:
Searcher searcher = new Searcher(ALGOLIA_APP_ID, ALGOLIA_SEARCH_API_KEY, ALGOLIA_INDEX_NAME);
searcher.setQuery(new Query("word").setExactOnSingleWordQuery(Query.ExactOnSingleWordQuery.ATTRIBUTE));
searcher.addNumericRefinement(new NumericRefinement("CountryId", NumericRefinement.OPERATOR_EQ, 1));
InstantSearch helper = new InstantSearch(this, searcher);
helper.setSearchOnEmptyString(false);
helper.search();
And this is the related xml layout:
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="6dp"
android:paddingRight="10dp"
android:paddingLeft="1dp"
android:paddingTop="6dp">
<com.algolia.instantsearch.ui.views.SearchBox
android:id="#+id/searchBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:queryHint="#string/search_text_hint"
algolia:searchIcon="#drawable/icn_search_big"
algolia:closeIcon="#drawable/icn_clear_filled_big"
android:queryBackground="#drawable/sarch_query_shape"
android:background="#drawable/search_shape"
algolia:autofocus="true"
algolia:submitButtonEnabled="false" />
</FrameLayout>`
<com.algolia.instantsearch.ui.views.Hits
android:id="#+id/hits"
android:layout_width="match_parent"
android:layout_height="match_parent"
algolia:autoHideKeyboard="true"
algolia:hitsPerPage="6"
android:layout_below="#+id/searchBarParentLayout"
algolia:infiniteScroll="false"
algolia:itemLayout="#layout/search_item_algolia_row"/>
Do you have any idea what can be the issue here?
I'm glad that the issue disappeared when you switched to another wifi.
For future readers that may encounter network issues with InstantSearch Android:
First of all, build and run one of our demo applications
If you see no problem running the example application, you can try using a proxy like Charles to investigate what's happening between your app and the network
If your problem persists when running the examples, or if you are following the documentation, send an email to support#algolia.com describing the issue with a sample of your code!
I am on a project. My instructor has told me to use MigLayout to design the forms in android. I am finding it difficult to find proper examples and while Using Eclipse for development its showing errors that android perfix is required to use the attributes.
please help me with some examples..
code that i pasted from the source site,mig4android.
<com.saynomoo.mig4android.MigLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
layout_constraints="wrap 4, debug 1"
column_constraints="[]15[75px]25[min]25[]"
row_constraints="[]15"
>
<TextView android:text="label1" component_constraints="skip"/>
<TextView android:text="label2" />
<TextView android:text="label3" component_constraints="wrap"/>
<TextView android:text="label4" />
<TextView android:text="label5" component_constraints="wmin 30"/>
<TextView android:text="label6" component_constraints="wmin 30"/>
<TextView android:text="label7" component_constraints="wmin 30"/>
</com.saynomoo.mig4android.MigLayout>
The component_constraints gave the error
This error means you forget to add android word before any attribute in xml file.
For example-
id="#+id/my_location"
You need to write android before id like below.
android:id="#+id/my_location"
Your code is perfect. But "skip" in component_constraints appears to be ignored. I had to manually add place holder to the layout to "fill in" empty spots. I tried "skip 1" and that also had no impact.
For more information see following link.
Skip as a constraint is not working
I'm sure this is something dead simple as it's my first android app with code (the hello world example I did was just assigning a value to a string in XML). My problem is when trying to get the reference for my button in my variable then the id as in R.id is not defined?
The compiler error is in a comment in the code below where it occurs:
package com.geeksonhugs.simplecalc;
import android.app.*;
import android.os.*;
import android.view.*;
import android.widget.*;
public class MainActivity extends Activity
{
private Button AddButton;
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
AddButton = (Button)findViewById(R.id.btnAdd);
//"Unknown member 'id' of 'com.geeksonhugs.simplecalc.R'"
//AddButton.setOnClickListener(this);
}
}
XML layout file:
<?xml version='1.0' encoding='utf-8' ?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/LayoutRoot"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:orientation="vertical">
<TextView
android:id="#+id/txtFirstNum"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:text="#string/strFirstNum" />
<EditText
android:id="#+id/edtFirstNum"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:text="" />
<TextView
android:id="#+id/txtSecondNum"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:text="#string/strSecondNum" />
<EditText
android:id="#+id/edtSecondNum"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:text="" />
<Button
android:id="#+id/btnAdd"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:text="#string/strAdd"
android:gravity="center" />
<TextView
android:id="#+id/txtResult"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:text="" />
</LinearLayout>
I resolved the issue by deleting the bin folder and recompiling using the AIDE App.
The R class is code-generated for you by the Android build tools when you build your project. This means there are four possibilities:
You have not tried building the project yet, in which case, try that.
Eclipse doesn't think it needs to build the project for some reason -- try Project > Clean from the Eclipse menu (only relevant if you are using Eclipse, of course).
There is some bug in your manifest or one of your resources that is preventing R from being built. There should be Eclipse error indicators for this.
You do not have an android:id attribute in your layout, and therefore there is no R.id available.
Please make sure the xml file you pasted is called main.xml and under layout folder.
And try to generate the R file again.
That may help.
For those using AIDE having issues referencing Id, try deleting the "gen folder" located in the bin folder and recompile. The problem is the R.java class did not create a constructor called Id. So deleting the gen folder containing the R.java class and recompiling solves this issue.
You must add id to a component in the XML file. Like this:
android:id="#+id/buton1"
Now can you click mainActivity.java and write code "R.id." you a see hint to write "buton1" and no error of "id"