Tampilkan postingan dengan label display. Tampilkan semua postingan
Tampilkan postingan dengan label display. Tampilkan semua postingan

How to display elements as such in html or Printing computer code

Posted by Unknown Kamis, 26 September 2013 0 komentar
How to display elements as such in html (eg: computer code) :
<html>
<body>

The pre tag is good for displaying computer code:


<pre>
for i = 1 to 10
print i
next i
</pre>

</body>
</html>

Baca Selengkapnya ....

Displaying Comment Line in HTML Document

Posted by Unknown Jumat, 20 September 2013 0 komentar
How to display comment line in html document has been given below :

<html>
<body>


This is a regular paragraph

</body>
</html>

Baca Selengkapnya ....

Using DialogFragments in Android

Posted by Unknown Minggu, 17 Februari 2013 0 komentar
MainActivity.java :
public class MainActivity extends FragmentActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
FragmentManager fm = getSupportFragmentManager();
dialogfragment testDialog = new dialogfragment();
testDialog.setRetainInstance(true);
testDialog.show(fm, "fragment_name");
}}
Dialogfragment.java :
public class Dialogfragment extends DialogFragment {    
public void TestDialog() {
// Empty constructor required for DialogFragment
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.dialog, container);
return view;
} }
dialog.xml :
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/edit_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="vertical">
<TextView
android:id="@+id/lbl_your_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello from Mark's Playground, DialogFragment Demo"/>
</LinearLayout>

  


Baca Selengkapnya ....

ContextMenu in Android

Posted by Unknown Kamis, 17 Januari 2013 0 komentar
Long click on the button to open the menu.
in java class:

public class ContextmenuActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

Button b=(Button)findViewById(R.id.button1);
registerForContextMenu(b);
}
//create the menuuu======================
@Override
public void onCreateContextMenu(ContextMenu menu, View v,
ContextMenuInfo menuInfo) {
// TODO Auto-generated method stub
super.onCreateContextMenu(menu, v, menuInfo);
MenuInflater inflater=getMenuInflater();
inflater.inflate(R.layout.contextmenu, menu);

}
//click to each menu======================
@Override
public boolean onContextItemSelected(MenuItem item) {
// TODO Auto-generated method stub
if(item.getItemId()==R.id.item1)
{
System.out.println("item1 clicked");
}
if(item.getItemId()==R.id.item2)
{
System.out.println("item2 clicked");
}
if(item.getItemId()==R.id.item3)
{
System.out.println("item3 clicked");
}
if(item.getItemId()==R.id.item4)
{
System.out.println("item4 clicked");
}
return super.onContextItemSelected(item);
}}

Context Menu Xml:

< ?xml version="1.0" encoding="utf-8"?>
< menu xmlns:android="http://schemas.android.com/apk/res/android">
< group android:checkableBehavior="single">
< item android:id="@+id/item1" android:title="Item 1" />
< item android:id="@+id/item2" android:title="Item 2" />
< item android:id="@+id/item3" android:title="Item 3" />
< item android:id="@+id/item4" android:title="Item 4" />
< /group>
< /menu>
in main Xml:

< ?xml version="1.0" encoding="utf-8"?>
< RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:gravity="center">
< Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
< /RelativeLayout>
         

Baca Selengkapnya ....

Custom AlertBox in Android

Posted by Unknown Rabu, 16 Januari 2013 0 komentar
in main.xml file:

< ?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="fill_parent"
android:orientation="vertical" >

< Button
android:id="@+id/button1"
android:layout_width="120dp"
android:layout_height="wrap_content"
android:text="Button" />

< /LinearLayout>
in dialog.xml :(xml for custom dialog box) :

< ?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="fill_parent"
android:orientation="vertical" >

< ImageView
android:id="@+id/imageView1"
android:layout_width="210dp"
android:layout_height="232dp"
android:padding="40dp"
android:src="@drawable/flower" />

< TextView
android:id="@+id/textView1"
android:layout_width="147dp"
android:layout_height="wrap_content"
android:text="This is a flower"
android:textSize="20dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="10dp"/>

< /LinearLayout>
in java file:

Button b= (Button) findViewById(R.id.button1);
b.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Dialog d=new Dialog(CustomdialogActivity.this);
d.setContentView(R.layout.dialog);
d.setTitle("This is important");
d.show();
}
});


Baca Selengkapnya ....

Read from Asset and Write to a TextView

Posted by Unknown Jumat, 11 Januari 2013 0 komentar
Code for reading from a text file in asset folder to a textview:


public class Readfile extends Activity {
String path;
ArrayList data = new ArrayList();

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
path = getResources().getString(R.string.directory1);
String[] data1 = null;
AssetManager am = getResources().getAssets();
try {
data1 = am.list(path);
} catch (Exception e) {
}
for (String name : data1) {
data.add(name);
}
Readoperation();
}
public void Readoperation() {
// TODO Auto-generated method stub
TextView txt = (TextView) findViewById(R.id.text);
try {
path=getResources().getString(R.string.directory1) +"/"+data.get(2);
InputStream stream = getAssets().open(path);
int size = stream.available();
byte[] buffer = new byte[size];
stream.read(buffer);
stream.close();
txt.setText(Html.fromHtml(new String(buffer).trim()));
}
catch (IOException e) {
}}

Baca Selengkapnya ....

Working with images in Corona

Posted by Unknown Kamis, 03 Januari 2013 0 komentar
Loading an Image :
syntax:
display.newImage( filename [, baseDirectory] [, left, top] )
example:
newImage = display.newImage( "image.png", 10, 20 ) myImage2 = display.newImage( "image.png" )
Image Autoscaling:
The default behavior of display.newImage() is to auto-scale large images.To control manually we can use boolean value.
syntax:
display.newImage( [parentGroup,] filename [, baseDirectory] [, x, y] [,isFullResolution] )
example:
newImage = display.newImage( "image.png", 10, 20, true )
Images with Dynamic Resolution :
syntax:
display.newImageRect( [parentGroup,] filename [, baseDirectory] w,h )
example:
newImage = display.newImageRect( "Image.png", 100, 100 )

Baca Selengkapnya ....
Trik SEO Terbaru support Online Shop Baju Wanita - Original design by Bamz | Copyright of android populer.