Activity to Fragment Dönüşümü ?
Selamlar;
Elimde var olan bir class'ı yeni uğraştığım projeye eklemek istiyorum. Fakat eski kodları (aşağıdakiler) Fragment yapısına getirmeye çalışıyorum. Bazı denemeler yaptım fakat başarıya ulaşamadım. Çözüm önerisi arıyorum. Teşekkür ederim.
[code]
public class CanvasActivity extends Activity
{
FrameLayout layout;
GridDesign myGrid;
int oldItemType = 0;
int requestedCode;
boolean useAdds = true;
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
requestWindowFeature(1);
Object localObject = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
layout = new FrameLayout(getApplicationContext());
layout.setLayoutParams((ViewGroup.LayoutParams) localObject);
myGrid = new GridDesign(getApplicationContext());
localObject = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
myGrid.setLayoutParams((ViewGroup.LayoutParams) localObject);
layout.addView(myGrid);
localObject = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
((FrameLayout.LayoutParams) localObject).gravity = 83;
((FrameLayout.LayoutParams) localObject).setMargins(10, 60, 10, 10);
myGrid.setFocusable(true);
myGrid.setFocusableInTouchMode(true);
setContentView(layout);
}
protected void onActivityResult(int paramInt1, int paramInt2, Intent paramIntent)
{
super.onActivityResult(paramInt1, paramInt2, paramIntent);
try
{
if ((paramInt1 == requestedCode) && (paramIntent.getData() != null))
{
Intent localIntent = new Intent();
localIntent.setAction("android.intent.action.SEND");
localIntent.setType("image/jpeg");
localIntent.putExtra("android.intent.extra.STREAM", paramIntent.getData());
startActivity(localIntent);
}
}
catch (Exception ex)
{
ex.printStackTrace();
}
}
public void onConfigurationChanged(Configuration paramConfiguration)
{
super.onConfigurationChanged(paramConfiguration);
}
public boolean onKeyDown(int paramInt, KeyEvent paramKeyEvent)
{
boolean bool;
switch (paramInt)
{
case 82:
bool = super.onKeyDown(paramInt, paramKeyEvent);
break;
default:
bool = myGrid.onKeyDown(paramInt, paramKeyEvent);
break;
}
return bool;
}
public void mStartActivity(Intent i)
{
startActivity(i);
}
public Context mGetContext() {
return CanvasActivity.this;
}
}
[/code]