[Solved] how to convert Date in to Feb 26, 2016 in java [duplicate]

import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static void main(String[] args) throws ParseException { String theInDate = “2/20/2016”; String theInFormat = “MM/dd/yyyy”; String theOutFormat = “MMM dd, yyyy”; final SimpleDateFormat theSdfInputFormatter = new SimpleDateFormat(theInFormat); final SimpleDateFormat theSdfOutputFormatter = new SimpleDateFormat(theOutFormat); final Date theDate = theSdfInputFormatter.parse(theInDate); final String theDateText = theSdfOutputFormatter.format(theDate); System.out.println(theDateText); … Read more

[Solved] What is an Activity in Android? [closed]

Can anyone please explain what is exactly an ‘Activity’ means in Android ? An activity is your main “coarse” unit of user interface. It is roughly analogous to a screen, page, window, or other similar construct in other GUI environments. Or, to quote the documentation: An Activity is an application component that provides a screen … Read more

[Solved] Android force close when using setBackgroundColor and setImageDrawable in loop [closed]

You need to create imageview dynamically. ImageView images[]; View shelfRow[] =new View[numberOfRows]; for (int i = 0; i < numberOfRows; i++) { images = new ImageView[numberOfRows]; shelfRow[i].setBackgroundResource(R.drawable.shelf_row2); images[i].setBackgroundColor(android.R.color.black); parentPanel.addView(shelfRow[i]); } Or create 10 imageviews and give id to it like.. int[] buttonIDs = new int[] {R.id.button1ID, R.id.button2ID, R.id.button3ID, … }; View shelfRow[] =new View[numberOfRows]; ImageView[] … Read more

[Solved] Cannot resolve method ‘findViewById(int)’ in Fragment of ViewPager [duplicate]

If you want to access any view, you have view object to access it. public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.frag1,container,false); btn = (Button)view.findViewById(R.id.button); return view; } solved Cannot resolve method ‘findViewById(int)’ in Fragment of ViewPager [duplicate]

[Solved] how can i create custom view with a textview along with an edittext?

Try this : <?xml version=”1.0″ encoding=”utf-8″?> <LinearLayout xmlns:android=”http://schemas.android.com/apk/res/android” android:layout_width=”fill_parent” android:layout_height=”wrap_content” android:clickable=”true” android:orientation=”vertical” > <LinearLayout android:layout_width=”match_parent” android:layout_height=”wrap_content” android:background=”#c8b560″ android:orientation=”vertical” android:padding=”7dip” > <TextView android:id=”@+id/name” android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:padding=”2dip” android:text=”Name” android:textAppearance=”?android:attr/textAppearanceMedium” /> <EditText android:id=”@+id/name_value” android:layout_width=”match_parent” android:layout_height=”wrap_content” android:ems=”10″ android:inputType=”textPersonName” /> </LinearLayout> </LinearLayout> solved how can i create custom view with a textview along with an edittext?

[Solved] Day of week Android [closed]

If I am understand You the right way, it must be something like this: Create a method like this: private void setDay(boolean dayIncrement){ Calendar cal = Calendar.getInstance(); //get an instance of Calenar int dayOfWeek = cal.get(Calendar.DAY_OF_WEEK); //get the current day switch (dayOfWeek) { //if it is monday…. case Calendar.MONDAY: text1.setText(“some text for MONDAY”); //if the … Read more

[Solved] How to create layout like in this image? [closed]

Not sure is this what you want. You may try. <RelativeLayout xmlns:android=”http://schemas.android.com/apk/res/android” android:layout_width=”match_parent” android:layout_height=”wrap_content” android:orientation=”horizontal” android:gravity=”start” android:background=”@android:color/white” android:padding=”12dp”> <ImageView android:id=”@+id/image” android:layout_width=”80dp” android:layout_height=”70dp” android:layout_centerVertical=”true” android:layout_gravity=”left”/> <RelativeLayout android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:layout_toRightOf=”@+id/image” android:layout_centerVertical=”true” android:paddingLeft=”6dp” android:orientation=”vertical” android:layout_alignParentRight=”true” android:layout_alignParentEnd=”true”> <LinearLayout android:id=”@+id/ll1″ android:layout_width=”match_parent” android:layout_height=”wrap_content” android:orientation=”horizontal”> <TextView android:id=”@+id/name” android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:textSize=”18sp” android:text=”Depeche Mode” android:singleLine=”true” /> </LinearLayout> <LinearLayout android:id=”@+id/ll2″ android:layout_below=”@+id/ll1″ android:layout_width=”match_parent” android:layout_height=”wrap_content” android:orientation=”horizontal”> <TextView … Read more

[Solved] How to convert jsonstring to jsonobject in android?

You can try like this, and your root is Json array not jsonobject try { JSONArray jsonArray = new JSONArray(d); if(jsonArray != null) { for (int i = 0; i < jsonArray.length(); i++) { JSONObject jsonObject = jsonArray.optJSONObject(i); if(jsonObject == null) { continue; } String name = jsonObject.optString(“name”); String isMe = jsonObject.optString(“isMe”); String time = … Read more

[Solved] Crash if digit is more than 9

@Fay Zan Basically you don’t want user to input more than 9 digits for your field, This can be achieved using two ways programmatically or using layout views properties, In you xml simple give this attribute to your EditText android:maxLength=”9″ OR programmatically by checking the length of your field. for example suppose the id of … Read more